You are on page 1of 3

Q1

#include <stdio.h>
int main()
{
int n, i;

printf("Enter a Number ");


scanf_s("%d", &n);

for (i = 5; i <= 15; ++i)


{
printf("%d * %d = %d \n", n, i, n*i);
}

getch();

Q2
Using Else-if
#include <stdio.h>
int main()
{
int week;

printf("Enter The Day (1-7) ");


scanf_s("%d", &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();
}

USING CASE STATEMENT

#include <stdio.h>
int main()
{
int week;

printf("Enter The Day (1-7) ");


scanf_s("%d", &week);
switch (week)
{
case 1:

printf("You Have Your Swimming Class");


break;

case 2:

printf("You Have to complete your assignment");


break;

case 3:

printf("You need to go to gym");


break;

case 4:

printf("You need to go to your driving lessons");


break;

case 5:

printf("Dont Be Late For Your Friday Prayer");


break;

case 6:

printf("You Dont Have Anything To Do");


break;

case 7:

printf("you have your english class");


break;

default:
printf("Invalid input Please enter week between 1-7");
break;
}
_getch();
}

Q4

#include <stdio.h>

int main()
{
int date;
int day;

printf("Enter Date Of July 2021 \n");


scanf_s("%d", &date);

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();

You might also like