C Program to Check Student Division विद्यार्थी की Division ज्ञात करने का C Program
In C language, we can use the if-else if-else statement to check a student's division based on percentage of marks. This program checks whether a student has secured First, Second, or Third Division, or has failed. It also handles invalid percentages.
C भाषा में if-else if-else statement का उपयोग विद्यार्थी की percentage के आधार पर उसकी division ज्ञात करने के लिए किया जाता है। यह program First, Second, Third Division या Fail की जाँच करता है। साथ ही, यह invalid percentage को भी handle करता है।
C Program
#include <stdio.h>int main(void){float per;printf("Enter Percentage of marks\n");scanf("%f", &per);if (per < 0 || per > 100)printf("Invalid Percentage\n");else if (per >= 60)printf("First Division\n");else if (per >= 45)printf("Second Division\n");else if (per >= 33)printf("Third Division\n");elseprintf("Fail\n");return 0;}
Output
Example 1:
Enter Percentage of marks75First Division
Example 2:
Enter Percentage of marks52Second Division
Example 3:
Enter Percentage of marks38Third Division
Example 4:
Enter Percentage of marks25Fail
Example 5:
Enter Percentage of marks105Invalid Percentage
Explanation
per < 0 || per > 100checks whether the percentage is invalid.per >= 60checks for First Division.per >= 45checks for Second Division.per >= 33checks for Third Division.If none of these conditions is true, the program displays Fail.
यह program सबसे पहले जाँचता है कि percentage 0 से कम या 100 से अधिक तो नहीं है। यदि percentage invalid है, तो Invalid Percentage प्रदर्शित होता है। अन्यथा, विद्यार्थी की division जाँची जाती है।
Modern C Compatibility Note
This program uses standard C features and is compatible with modern C compilers such as GCC, Clang, and Visual Studio C.
Note: The division criteria used in this program are illustrative. Actual division criteria may vary according to the rules of the relevant board or institution.
This program demonstrates how to use if-else if-else statements to check student division and handle invalid percentage values in C.
यह program C भाषा में if-else if-else statement का उपयोग करके विद्यार्थी की division तथा invalid percentage की जाँच करना सिखाता है।
Comments
Post a Comment