Write a C C++ program to find total and percent

 

Flowchart

Find total and percent flowchart

 

Coding in C

#include<stdio.h>
int main()
{
int s1,s2,s3,s4,s5,t;
float p;
printf(“Enter marks of five subjects: “);
scanf(“%d%d%d%d%d”,&s1,&s2,&s3,&s4,&s5);
t=s1+s2+s3+s4+s5;
p=t/5.0;
printf(“Total = %d Percent = %f”,t,p);
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
int s1,s2,s3,s4,s5,t;
float p;
cout<<“Enter marks of five subjects: “;
cin>>s1>>s2>>s3>>s4>>s5;
t=s1+s2+s3+s4+s5;
p=t/5.0;
cout<<“Total = “<<t<<” Percent = “<<p;
return 0;
}

 

Output

Find total and percent output

 

Published by

admin

I am a computer teacher, programmer and web developer