How do you write a c program that calculates vacation days by years of employment?

1 answer

Answer

1014273

2026-07-28 22:10

+ Follow

To write a C program that calculates vacation days based on years of employment, you can start by defining the number of vacation days per year of service. For example, you might allocate 10 days for the first five years, then increase it to 15 days for the next five years. Use a loop to take user input for years of employment, and then employ conditional statements to determine the total vacation days. Finally, display the result to the user. Here’s a simple structure:

<code class="language-c">#include <stdio.h>

int main() { int years; printf("Enter years of employment: "); scanf("%d", &years); int vacation_days = (years <= 5) ? years * 10 : (5 * 10) + ((years - 5) * 15); printf("Total vacation days: %d\n", vacation_days); return 0; }

</code>
ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.