Professional Documents
Culture Documents
#include <stdio.h>
int main()
{
int n, i;
getch();
Q2
Using Else-if
#include <stdio.h>
int main()
{
int week;
if (week == 1)
{
printf("You Have Your Swimming Class");
}
else if (week == 2)
{
printf("You Have to complete your assignment");
}
else if (week == 3)
{
printf("You need to go to gym");
}
else if (week == 4)
{
printf("You need to go to your driving lessons");
}
else if (week == 5)
{
printf("Dont Be Late For Your Friday Prayer");
}
else if (week == 6)
{
printf("You Dont Have Anything To Do");
}
else if (week == 7)
{
printf("you have your english class");
}
else
{
printf("Invalid input Please enter week between 1-7");
}
_getch();
}
#include <stdio.h>
int main()
{
int week;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
default:
printf("Invalid input Please enter week between 1-7");
break;
}
_getch();
}
Q4
#include <stdio.h>
int main()
{
int date;
int day;
if (date == 15 )
{
printf("Your Today Activities Are:Playing Soccer,Attend Your Class");
}
else if (date != 15 )
{
printf("Your Today Activities Are:Going To The Gym,Play Cricket");
}
else
printf("Today is not thursday or 15july So no activities today");
_getch();