Tuesday, April 14, 2020

Nested else-if statement in C

  • Flowchart :
  • Syntax :
if (condition)
    statement;
else if (condition)
    statement;
.
.
else
    statement;
  • Program :
#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3,s4,s5,sum;
        float total;
        clrscr();
        printf("\n----------------NESTED ELSE-IF STATEMENT----------------");
        Printf("\nEnter Tamil mark :");
        scanf("%d",&s1);
        Printf("\nEnter English mark :");
        scanf("%d",&s2); 
        Printf("\nEnter Maths mark :");
        scanf("%d",&s3);
        Printf("\nEnter Science mark :");
        scanf("%d",&s4);
        Printf("\nEnter Social mark :");
        scanf("%d",&s5);
        sum=s1+s2+s3+s4+s5;
        Printf("\nOver all marks is :%d",sum);
        total=sum/5;
        Printf("\nOver all percentage is :%d",sum);
if(total>75){
printf("First class");
}
else if(total>65){
printf("Second class");
}
else if(total>55){
printf("Third class");
}
else{
printf("Fourth class");
}
getch();
}

  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...