Skip to main content

Write a C C++ program to find total and percent from marks obtained


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

Write a C C++ program to find total and percent from marks obtained