C++ Program to Calculate Percentage and Display Division Using if-else (प्रतिशत एवं डिवीजन ज्ञात करना)
This C++ program accepts the percentage of a student and displays the division based on the percentage obtained using nested if-else statements.
यह C++ प्रोग्राम विद्यार्थी का प्रतिशत input करता है तथा nested if-else statements की सहायता से प्राप्त प्रतिशत के आधार पर उसकी division प्रदर्शित करता है।
Program:
#include <iostream>using namespace std;int main(){float per;cout << "Enter Percentage of student: ";cin >> per;if (per >= 60){cout << "I Division " << per << "%" << endl;}else{if (per >= 45){cout << "II Division " << per << "%" << endl;}else{if (per >= 33){cout << "III Division " << per << "%" << endl;}else{cout << "Fail !! " << per << "%" << endl;}}}return 0;}
Output 1:
Enter Percentage of student: 75I Division 75%
Output 2:
Enter Percentage of student: 50II Division 50%
Output 3:
Enter Percentage of student: 40III Division 40%
Output 4:
Enter Percentage of student: 25Fail !! 25%
Explanation (व्याख्या)
The program checks the percentage using the following conditions प्रोग्राम निम्न conditions के आधार पर percentage check करता है:
If
per >= 60, the student gets First Division. यदिper >= 60है, तो First Division प्रदर्शित होती है।Otherwise, if
per >= 45, the student gets Second Division. अन्यथा यदिper >= 45है, तो Second Division प्रदर्शित होती है।Otherwise, if
per >= 33, the student gets Third Division. अन्यथा यदिper >= 33है, तो Third Division प्रदर्शित होती है।If all the above conditions are false, the student is declared failed. यदि सभी conditions false होती हैं, तो विद्यार्थी को fail घोषित किया जाता है।
This program demonstrates the use of nested if-else statements to determine a student's division based on the percentage obtained.
यह प्रोग्राम प्राप्त प्रतिशत के आधार पर विद्यार्थी की division निर्धारित करने के लिए nested if-else statements का प्रयोग दर्शाता है।
Comments
Post a Comment