Skip to main content

C++ Program to Find Grade of a Student using if else

Programming Languages

 Welcome to coding world

C++ Program to Find Grade of a Student using if else

Write a C++ Program to Find Grade of a Student using if else. Here’s simple C++ Program to Find Grade of a Student using if else in C++ Programming Language.

Numbers in C++

Normally, when we work with Numbers, we use primitive data types such as int, short, long, float and double, etc. The number data types, their possible values and number ranges have been explained while discussing C++ Data Types.

To calculate grade of a student on the basis of his total marks in C++ Programming, you have to ask to the user to enter marks obtained in some subjects.

To calculate grade of student, first calculate the mark’s sum of all the subjects and then calculate average marks. Now start checking for the grades to display the result as shown here in the following program.

Here is source code of the C++ Program to Find Grade of a Student using if else. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

 SOURCE CODE : 

/*  C++ Program to Find Grade of a Student using if else  */

 

#include<iostream>

using namespace std;

 

int main()

{

        int mark[5], i;

        float sum=0,avg;

 

        cout<<"\nEnter Marks in 5 subjects :: \n";

        for(i=0; i<5; i++)

        {

            cout<<"\nEnter Marks[ "<<i+1<<" ] :: ";

                cin>>mark[i];

                sum=sum+mark[i];

        }

 

        avg=sum/5;

 

        cout<<"\nYour Grade is :: ";

        if(avg>80)

        {

                cout<<"[ A ]\n";

        }

        else if(avg>60 && avg<=80)

        {

                cout<<"[ B ]\n";

        }

        else if(avg>40 && avg<=60)

        {

                cout<<"[ C ]\n";

        }

        else

        {

                cout<<"[ D ]\n";

        }

 

        return 0;

}


OUTPUT :

/*  C++ Program to Find Grade of a Student using if else  */

 

Enter Marks in 5 subjects ::

 

Enter Marks[ 1 ] :: 78

 

Enter Marks[ 2 ] :: 87

 

Enter Marks[ 3 ] :: 67

 

Enter Marks[ 4 ] :: 99

 

Enter Marks[ 5 ] :: 90

 

Your Grade is :: [ A ]

 

Process returned 0

Above is the source code for C++ Program to Find Grade of a Student using if else which is successfully compiled and run on Windows System. The Output of the program is shown above.

 If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section. We will try our best to reach up to you in short interval.

Popular posts from this blog

Key Ecommerce Leader (KEL) Pakistan Awards Event 2024 | Pakistan KEL Awards Winner Tayyub Hussnain (Norwich Street Wear) | 2024 Alibaba.com Pakistan Key E-commerce Leader Winner

 Key Ecommerce Leader (KEL) Pakistan Awards Event 2024 On August 20, 2024, Alibaba.com organized an exceptional event at the Pearl Continental Hotel in Lahore. Participants gained insights into global business strategies and discovered the vast opportunities available through Alibaba.com. In an exciting development, Alibaba.com announced the launch of Trade Assurance in Pakistan by the end of August 2024, representing a significant advancement for the Pakistani market. Featured speakers included: 🌟 Andrew Zheng - Vice President, Alibaba.com 🌟 Vianne Wang - Head of Global Supply Chain, Alibaba.com 🌟 Winni Chen - Merchant Development Manager The event was a resounding success, enhancing confidence in the future of eCommerce in Pakistan! 💪🎉 During the event, six successful business owners were invited to share their stories and insights. Mr.Tayyub Hussnain stood out with his inspiring success story and impressive leadership skills, captivating the audience and judges alike. Ho...

Pakistan celebrities real ages 2021

  Pakistani Celebrities Ages 2021 A few celebrities hide their age since they have to be shape us get it that they are still energetic. So let’s take a see at the Veritable Age of Pakistani Celebrities and see which celebrity ceaselessly lie around his/her age. 1: Ayeza Khan 15 January 1987 2: Mehwish Hayat 6 January 1988 3: Saba Qamar 5 April 1987 4: Sajal Alay 17 January 1994       5: Sara Khan 14 July 1992 6: Iqra Aziz 24 November 1997     7: Alizeh Shah 9 June 2000 8: Zara Noor Abbas 13 March 1991 9: Saboor Aly 3 March 1995 10: Hina Altaf 2 January 1992 11: Sana Javed   25 March 1993 12: Momal Sheikh   6 April 1986 13: Hiba Bukhari 27 July 1993 14: Hira Mani 27 February 1989 15: Aiman Khan 20 November 1998 16: Minal Khan 20 November 1998 17: Kinza Hashmi 7 March 1997 18: Kubra Khan  16 June 1993 19: Mawra Hoccane 28 September 1992 20: Urwa Hoccane 2 July 1991 21: Ha...

Sad urdu poetry