C Program to Find First Division Using if Block if ब्लॉक का उपयोग करके प्रथम श्रेणी (First Division) ज्ञात करना
In C language, the if statement is used to execute a block of code when a given condition is true. In this program, we check whether a student's percentage is 60 or more. If the condition is true, the program displays First Division.
C भाषा में if statement का उपयोग किसी condition के true होने पर code को execute करने के लिए किया जाता है। इस program में हम जाँचते हैं कि विद्यार्थी के अंक 60 प्रतिशत या उससे अधिक हैं या नहीं। यदि condition true होती है, तो program First Division प्रदर्शित करता है।
C Program
#include<stdio.h>#include<conio.h>void main(){float per;clrscr();printf("Enter Percentage of marks\n");scanf("%f", &per);if(per >= 60)printf("First Division\n");getch();}
Output
Enter Percentage of marks75First Division
Explanation
float per;declares a variable to store the percentage.scanf("%f", &per);accepts the percentage from the user.if(per >= 60)checks whether the percentage is 60 or more.If the condition is true, First Division is displayed.
if(per >= 60) यह condition जाँचती है कि percentage 60 या उससे अधिक है या नहीं। यदि condition true होती है, तो First Division प्रदर्शित होता है।
Modern C Compatibility Note
This program uses conio.h, clrscr(), and getch(), which are not part of standard C. They are commonly used in older Turbo C environments.
For modern C compilers such as GCC, Clang, or standard-compliant Visual Studio C, remove #include<conio.h>, clrscr(), and getch(). Also, use int main(void) instead of void main().
A modern compatible version is:
#include <stdio.h>int main(void){float per;printf("Enter Percentage of marks\n");scanf("%f", &per);if (per >= 60)printf("First Division\n");return 0;}
This program demonstrates the use of a simple if statement in C to check whether a student has secured First Division based on percentage.
यह program C भाषा में simple if statement का उपयोग करके विद्यार्थी की percentage के आधार पर First Division जाँचना सिखाता है।
Comments
Post a Comment