Write a simple program , to show the student passed or fail , when the
percentage is entered.
Answers
Answer:
Mark me as brainliest
Explanation:
#include <stdio.h>
int main(void){
int num;
printf("Enter your mark ");
scanf("%d",&num);
printf(" You entered %d", num); // printing outputs
if(num >= 80){
printf(" You got A grade"); // printing outputs
}
else if ( num >=60){ // Note the space between else & if
printf(" You got B grade");
}
else if ( num >=40){
printf(" You got C grade");
}
else if ( num < 40){
printf(" You Failed in this exam");
}
return 0;
}
Answer:
The C program to display student results demonstrates the working of conditional statement in the C language. The program takes student’s marks in percentage (%) as input , process the input value and displays the results (pass or fail) as output.
The output depends on the conditional statement in the example program.
Learn C programming basics before you begin with this example program.
C Arithmetic Operators
C Data Types
C Printing Outputs
C Flow Control Structures
Problem Definition
The program decides whether a student has passed or failed an exam. If the input is in percentage mark ( say 70%), a simple conditional statement checks if given percentage mark is below 40%.
( mark < 40)
The student result is a pass when mark is above 40% , else the student has failed. The result is displayed at the console.
Here we list the steps involved in processing input values.
Receive input in percentage mark (%)
Check if the given mark is above below 40%
If below 40%, then the student has failed
Else the student passed.
Display the result.
Flowchart – Program to Display Student Results
The program start at the top (Start) and terminates where it says, (End) in the flowchart.
Flowchart - C Program to Display Student Results
Flowchart – C Program to Display Student Results
Program Code – Program to Display Student Results
/*Show result of student using Marks */
#include <stdio.h>
#include <conio.h>
int main()
{
int marks,i;
/* Read student marks */
printf("Enter the marks (in percentage ) of Student:");
scanf("%d",&marks);
/* display result */
if(marks < 40)
{
for(i=0;i<40;i++)
printf("_");printf("\n\n");
printf("Result = Failed\n");
for(i=0;i<40;i++)
printf("_");printf("\n\n");
}
else
{
for(i=0;i<40;i++)
printf("_");printf("\n\n");
printf("Result = Passed\n");
for(i=0;i<40;i++)
printf("_");printf("\n\n");
}
system("pause");
return 0;
} hope it will help you
plz mark me as brainlist