WAP, Write a program to calculate the total marks & percentage of given five subject & find whether he/she is pass or not with output
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,m,f;
clrscr();
printf ("Enter the marks:");
scanf ("\n %d %d %d %d %d ", &a, &b, &c, &d, &e);
f=(a+b+c+d+e)/5;
printf("Avg. is :%d", f);
printf ("\n Percentage is:%d\n", f);
if(f>=66)
{
printf("Distinction");
}
else if (f<=66 && f>60)
{
printf("First Class");
}
else if(f<=60 && f>50)
{
printf("Second Class");
}
else if(f<=50 && f>40)
{
printf("Pass");
}
else
{
printf("Fail");
getch();
}
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.
Click here to check the output
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,m,f;
clrscr();
printf ("Enter the marks:");
scanf ("\n %d %d %d %d %d ", &a, &b, &c, &d, &e);
f=(a+b+c+d+e)/5;
printf("Avg. is :%d", f);
printf ("\n Percentage is:%d\n", f);
if(f>=66)
{
printf("Distinction");
}
else if (f<=66 && f>60)
{
printf("First Class");
}
else if(f<=60 && f>50)
{
printf("Second Class");
}
else if(f<=50 && f>40)
{
printf("Pass");
}
else
{
printf("Fail");
getch();
}
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.
Click here to check the output
No comments:
Post a Comment