C Program to Find First Division of a Student Using if Statement
In C language, we can use the if statement to check whether a student has secured first division based on their percentage of marks. Generally, a percentage of 60% or above is considered first division in this example.
C लैंग्वेज में if स्टेटमेंट का उपयोग करके यह चेक किया जा सकता है कि किसी विद्यार्थी ने प्राप्त अंकों के प्रतिशत के आधार पर प्रथम श्रेणी प्राप्त की है या नहीं। इस उदाहरण में 60% या उससे अधिक अंक प्राप्त करने पर प्रथम श्रेणी मानी गई है।
Program
#include <stdio.h>int main(void){float per;printf("Enter percentage of marks: ");if (scanf("%f", &per) != 1 || per < 0 || per > 100){printf("Invalid percentage.\n");return 1;}if (per >= 60){printf("First Division\n");}return 0;}
Output 1
Enter percentage of marks: 75First Division
Output 2
Enter percentage of marks: 45Explanation
The program accepts the percentage of marks from the user and stores it in the variable
per.प्रोग्राम यूजर से प्राप्त अंकों का प्रतिशत इनपुट के रूप में लेता है और उसे
perवेरिएबल में स्टोर करता है।The
ifstatement checks whether the percentage is greater than or equal to 60.ifस्टेटमेंट यह चेक करता है कि प्रतिशत 60 या उससे अधिक है या नहीं।If the condition is true, the program displays the message First Division.
यदि कंडीशन सही होती है, तो प्रोग्राम First Division मैसेज प्रदर्शित करता है।
If the condition is false, the statement inside the
ifblock is skipped.यदि कंडीशन गलत होती है, तो
ifब्लॉक के अंदर लिखा गया स्टेटमेंट स्किप हो जाता है।
In this program, only an if statement is used. If the percentage is less than 60, no message is displayed because there is no else block.
इस प्रोग्राम में केवल if स्टेटमेंट का उपयोग किया गया है। यदि प्रतिशत 60 से कम है, तो कोई मैसेज प्रदर्शित नहीं होता क्योंकि इसमें else ब्लॉक का उपयोग नहीं किया गया है।
The 60% first-division criterion is an assumption for this educational example. Actual division criteria may differ according to the rules of the university or examination board.
Comments
Post a Comment