Question
Hello I wrote this C program and it does compile with gcc- Wall. but when i try to run it it does not work and
Hello I wrote this C program and it does compile with gcc- Wall. but when i try to run it it does not work and it gives an error """"
./due_date.c: line 3: syntax error near unexpected token `('
./due_date.c: line 3: `int main ()'"
this is the program
#include
#include
int main ()
{
/*defining local variables*/
int todays_date;
int number_of_days;
int D;
/*Taking today's date and the number of days till due date from the user*/
printf("enter today's number 0 for sunday 1 for monday ect: ");
scanf("%d",&todays_date);
/*Checking for errors*/
if(todays_date<0 || todays_date>6){
printf("You entered an invalid number.. try again: ");
exit(1);
}
printf("enter number of days: ");
scanf("%d",&number_of_days);
/*Calculating days in total*/
D = (todays_date + number_of_days)%7;
switch(D)
{
case 0:printf("number of days allowed: %d ",number_of_days+1);
printf("the work is due on Monday ");
break;
case 1:printf("number of days allowed: %d ",number_of_days);
printf("the work is due on Monday ");
break;
case 2: printf("number of days allowed: %d ",number_of_days);
printf("the work is due on Tuesday ");
break;
case 3: printf("number of days allowed: %d ",number_of_days);
printf("the work is due on Wednesday ");
break;
case 4: printf("number of days allowed: %d ",number_of_days);
printf("the work is due on Thursday ");
break;
case 5: printf("number of days allowed: %d ",number_of_days+3);
printf("the work is due on Monday ");
break;
case 6: printf("%d ",number_of_days+2);
printf("the work is due on Monday ");
break;
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started