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: 75
First Division

Output 2

Enter percentage of marks: 45

Explanation

  1. The program accepts the percentage of marks from the user and stores it in the variable per.

    प्रोग्राम यूजर से प्राप्त अंकों का प्रतिशत इनपुट के रूप में लेता है और उसे per वेरिएबल में स्टोर करता है।

  2. The if statement checks whether the percentage is greater than or equal to 60.

    if स्टेटमेंट यह चेक करता है कि प्रतिशत 60 या उससे अधिक है या नहीं।

  3. If the condition is true, the program displays the message First Division.

    यदि कंडीशन सही होती है, तो प्रोग्राम First Division मैसेज प्रदर्शित करता है।

  4. If the condition is false, the statement inside the if block 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

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025