C Assignment
C Assignment
what a c program to find the largest of three numbers and draw the flow chart
#include<stdio.h>
int main()
int A,B,C,largest;
scanf("%d%d%d", &A,&B,&C);
if(A>B&&A>C)
largest=A;
else
largest=C;
if(B>A&&B>C)
largest=B;
else
largest=C;
return 0;
2.write a program in c that accept a grade as an input and display the equivalent description
as shown in the table below. (hint: using switch statement)
Input output
E Excellent
V Very good
G Good
A Average
F Fail
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void main()
{
char notes[15];
char grd;
printf("Input the grade :");
scanf("%c", &grd);
grd = toupper(grd);
switch(grd)
{
case 'E':
strcpy(notes, " Excellent");
break;
case 'V':
strcpy(notes, " Very Good");
break;
case 'G':
strcpy(notes, “ Good “);
break;
case ‘A’:
strcpy(notes, “ Average”);
break;
case ‘F’:
strcpy(notes, “ Fails”);
break;
default :
strcpy(notes, “Invalid Grade Found. \n”);
break;
}
printf(“You have chosen : %s\n”, notes);
}
3.write a program in c to read 10 numbers from keyboard and find their sum and average
(hint: use for loop) #include<stdio.h>
#include<stdio.h>
int main()
{
int i,n,sum=0;
float avg;
printf("input the 10 numbers:\n");
for(i=1;i<=10;i++)
{
printf("number -d%:",i);
scanf("%d",&n);
sum+=n;
}
avg=sum/10.0;
printf("the sum of 10 number is%d :\n average is :%f\n",sum,avg);}