C C++ program to find total percent and division

C C++ program to find total percent and division

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to find total percent and division

Flowchart to find total percent and division of five subjects

C program to find total percent and division

#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;
}

C++ program to find total percent and division

#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 of C C++ program to find total percent and division

Enter marks of five subjects:
40 50 60 70 81
Total     =  301
Percent   =  60.200001
Division  =  First
Enter marks of five subjects:
4 5 6 7 8
Total     =  30
Percent   =  6.000000
Division  =  Fail

List of all control statement programs in C C++

  1. Absolute value of number (simple if)
  2. Checking odd or even number (if else)
  3. Checking leap year (if else)
  4. Greater in two numbers (if else)
  5. Finding grade from percent (else if ladder)
  6. Greatest in three numbers (nested if)
  7. Simple calculator program (switch case single case)
  8. Switch between Mon to Sun (switch case single case)
  9. Checking vowel or consonant (switch case multiple case)
  10. Number of days in a month (switch case multiple case)
  11. Unconditional Branching (break continue and goto)
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer