C programming examples with output
Find result of a student
Program
#include<stdio.h>
#include<conio.h>
main()
{
int m1,m2,m3,m4,m5,m6,total;
char result,grade,name[15];
float avg;
clrscr();
printf("Enter student name: ");
scanf("%s",name);
printf("\nEnter 6 marks: ");
scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6);
total=m1+m2+m3+m4+m5+m6;
avg=total/6;
if(avg>40)
{
result= 'P';
if(avg>75)
grade='A';
else if(avg>60 && avg<=75)
grade='B';
else if(avg>50 && avg<=60)
grade='C';
else
grade='D';
}
else
result='f';
printf("\nStudent name : %s",name);
printf("\nMarks : ");
printf("\n%d\t%d\t%d\t%d\t%d\t%dt",m1,m2,m3,m4,m5,m6);
printf("\nAverage marks : %f",avg);
if(result=='p')
printf("\nResult : Pass");
else
printf("\nResult : fail");
printf("\nGrade : %c",grade);
getch();
}
Output
Enter student name: Prem
Marks :
65 69 73 80 90 97
Average result : 79.000000
Result : Pass
Grade : A
Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number:
Find result of a student
Program
#include<stdio.h>
#include<conio.h>
main()
{
int m1,m2,m3,m4,m5,m6,total;
char result,grade,name[15];
float avg;
clrscr();
printf("Enter student name: ");
scanf("%s",name);
printf("\nEnter 6 marks: ");
scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6);
total=m1+m2+m3+m4+m5+m6;
avg=total/6;
if(avg>40)
{
result= 'P';
if(avg>75)
grade='A';
else if(avg>60 && avg<=75)
grade='B';
else if(avg>50 && avg<=60)
grade='C';
else
grade='D';
}
else
result='f';
printf("\nStudent name : %s",name);
printf("\nMarks : ");
printf("\n%d\t%d\t%d\t%d\t%d\t%dt",m1,m2,m3,m4,m5,m6);
printf("\nAverage marks : %f",avg);
if(result=='p')
printf("\nResult : Pass");
else
printf("\nResult : fail");
printf("\nGrade : %c",grade);
getch();
}
Output
Enter student name: Prem
Marks :
65 69 73 80 90 97
Average result : 79.000000
Result : Pass
Grade : A
Check others programming by click here:
Factorial of a number:
Find sum of digits of a number:
Find vowel or not:
Palindrome Number: