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

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

C Language में Character set क्या होता है जानने के लिए देखें—Character set of C

C Language में Token क्या होता है जानने के लिए देखें—Tokens in C

Flowchart to find total and percent

Find total and percent flowchart

C program to find total and percent

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

C++ program to find total and percent

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

Enter marks of five subjects: 40 60 50 90 71
Total = 311 Percent = 62.2
Enter marks of five subjects: 78 45 81 90 66 
Total = 311 Percent = 72.000000

List of similar C and C++ programs

  1. Sum of two entered numbers
  2. Average of three entered numbers
  3. Simple interest
  4. Swapping values of two variables
  5. Swapping without using third variable
  6. Celsius to Fahrenheit conversion
  7. Find area and circumference of circle
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer