C C++ program to find total percent and division

Flowchart

Flowchart to find total percent and division of five subjects

Coding in C

#include<stdio.h>
int main()
{
    int s1,s2,s3,s4,s5,t;
    float p;
    printf("Enter marks of five subjects:\n");
    scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
    t=s1+s2+s3+s4+s5;
    p=t/5.0;
    printf("Total    = %d\n",t);
    printf("Percent  = %f\n",p);
    if(p>=60)
        printf("Division = First");
    else if(p>=45)
        printf("Division = Second");
    else if(p>=33)
        printf("Division = Third");
    else
        printf("Division = Fail");
    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: "<<endl;
    cin>>s1>>s2>>s3>>s4>>s5;
    t=s1+s2+s3+s4+s5;
    p=t/5.0;
    cout<<"Total    = "<<t<<endl;
    cout<<"Percent  = "<<p<<endl;
        if(p>=60)
        cout<<"Division = First";
    else if(p>=45)
        cout<<"Division = Second";
    else if(p>=33)
        cout<<"Division = Third";
    else
        cout<<"Division = Fail";
    return 0;
}

Output

Total percent and division program output

Published by

admin

I am a computer teacher, programmer and web developer