What is the difference between 'c' & 'c++? Write a program that will accept students' Names & marks in three languages. Calculate total & percentage. Check who has passed & who has failed under the following condition both in c & c++. Output should display the student name, three subject marks, total, percentage & result (pass or fail) both in c & c++ program. Condition: percentage> =50 then pass else fail
Answers
Answered by
0
c is structure oriented
c++ is object oriented
#include<stdio.h>
main()
{
int n,m1,m2,m3,t,p,r;
printf(Enter the name:);
scanf("%d",&n);
printf(Enter the marks:);
scanf("%d%d%d",&m1,&m2,&m3);
t=m1+m2+m3;
printf("The total is",t);
p=t×100%;
printf("The percentage is",p);
{
if(p>=50)
printf("pass",p);
else
printf("fail",p);
}
}
the same for c++
instead of printf() cin<< and scanf() cout<<
don't use %d in scanf for c++
c++ is object oriented
#include<stdio.h>
main()
{
int n,m1,m2,m3,t,p,r;
printf(Enter the name:);
scanf("%d",&n);
printf(Enter the marks:);
scanf("%d%d%d",&m1,&m2,&m3);
t=m1+m2+m3;
printf("The total is",t);
p=t×100%;
printf("The percentage is",p);
{
if(p>=50)
printf("pass",p);
else
printf("fail",p);
}
}
the same for c++
instead of printf() cin<< and scanf() cout<<
don't use %d in scanf for c++
Similar questions