Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! 🚀 🔹Learn advanced coding techniques in C& C++ 🔹Master Linux internals & shell scripting 🔹Deep dive into Data Structures & Algorithms 🔹Explore Embedded Systems & Microcontrollers (8051,UART, RTOS) 🔹Get hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
WAP to print the grade for a given percentage
Description :
You have to read a interger value from user, it should be less than 100.
*) if percentage is greater than 90 and less than or equal to 100 - 'A'
*) if percentage is greater than 70 and less than 91 - 'B'
*) if percentage is greater than 50 and less than 71 - 'C'
*) if percentage is less than or equal to 50 - 'F'
Sample Execution :
Test case 1 :
Enter the percentage : 95
The Grade is A
Test case 2 :
Enter the percentage : 115
Error : Please enter the percentage less than or equal to 100.
PROGRAM:
---------------------------------------------------------------------------------------------------------------
#include<stdio.h>
int main()
{
int percentage;
// printf("Enter the percentage:");
scanf("%d",&percentage);
if(percentage>=90 && percentage <=100)
{
printf("The Grade is A");
}
else if(percentage>=70 && percentage <=91)
{
printf("The Grade is B");
}
else if(percentage>=51 && percentage <=71)
{
printf("The Grade is C");
}
else if(percentage<=50)
{
printf("The Grade is F");
}
else
{
printf("Error : Please enter the percentage less than or equal to 100.");
}
}
---------------------------------------------------------------------------------------------------------------
sample input;
Enter the percentage:95
sample output;
The Grade is A
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment