Write a C C++ program to find grade from given percent

Write a C C++ program to find grade from given percent

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

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

Flowchart to find grade from given percent

Finding grade from given percent flowchart

C program to find grade from given percent

#include<stdio.h>
int main()
{
    float p;
    printf("Enter percent: ");
    scanf("%f",&p);
    if(p>=90)
    {
        printf("A+");
    }
    else if(p>=80)
    {
        printf("A");
    }
    else if(p>=60)
    {
        printf("B");
    }
    else if(p>=40)
    {
        printf("C");
    }
    else
    {
        printf("D");
    }
    return 0;
}

C++ program to find grade from given percent

#include<iostream>
using namespace std;
int main()
{
    float p;
    cout<<"Enter percent: ";
    cin>>p;
    if(p>=90)
    {
        cout<<"A+";
    }
    else if(p>=80)
    {
        cout<<"A";
    }
    else if(p>=60)
    {
        cout<<"B";
    }
    else if(p>=40)
    {
        cout<<"C";
    }
    else
    {
        cout<<"D";
    }
    return 0;
}

Output of C C++ program to find grade from given percent

Enter percent: 95
A+
Enter percent: 88
A
Enter percent: 62
B
Enter percent: 40
C
Enter percent: 25
D

Other if 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. Total percent and division (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