0% found this document useful (0 votes)
5 views3 pages

C Programs for Basic Input and Logic

The document contains C code that takes user input for a day number between 1-7 and prints the corresponding day of the week. It uses a switch statement to check the day number and print the day using printf statements in each case.

Uploaded by

mehick20
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

C Programs for Basic Input and Logic

The document contains C code that takes user input for a day number between 1-7 and prints the corresponding day of the week. It uses a switch statement to check the day number and print the day using printf statements in each case.

Uploaded by

mehick20
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

#include <conio.

h>
#include<stdio.h>
int main()
{
int day;
puts("enter day 1-7\n");
scanf_s("%d",&day);
switch (day)
{
case 1:
printf("monday\n");
break;
case 2:
printf("tuesday\n");
break;
case 3:
printf("wednesday\n");
break;
case 4:
printf("thursday\n");
break;
case 5:
printf("friday\n");
break;
case 6:
printf("saturday\n");
break;
case 7:
printf("sunday\n");

break;
}
getch();
return 0;
}

ACTIVITY:
# include<conio.h>
#include<stdio.h>
int main()
{
int age,marks;
float height;
printf("age of player\n");
scanf("%d",age);
if(age>16||age<20)
printf("age level is passed\n");
printf("height of player\n");
scanf("%f",height);
if(height==5.6)
printf("player passed");
printf("marks of player\n");
scanf("%d",marks);
if(marks>=60)
printf("student is passed\n");
else
printf("player is fail");
getch();
return 0;
}

ACTIVITY:
# include<conio.h>
#include<stdio.h>
int main()
{
int age,marks;
float height;
printf("age of player\n");
scanf("%d",age);
printf("height of player\n");
scanf("%f",height);
printf("marks of player\n");
scanf("%d",marks);
if (age>=16&&height==5.6&&marks>60)
printf("student is passed\n");
else
printf("player is fail");

getch();
return 0;
}

ACTIVITY:
#include<stdio.h>
#include<conio.h>
int main(){
int n,i;
int sum=0;
printf("Enter the n\n");
scanf("%d",&n);
sum = (n * (n + 1)) / 2;
printf("Sum of the numbers\n ");
for(i =1;i <= n;i++)
{
if (i!=n)
printf("%d ",i);
else
printf("%d = %d ",i,sum);
}
getch();
return 0;
}

You might also like