Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

C Programs Using Nestedif and Elseif Ladder

C program

Uploaded by

raagavi109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

C Programs Using Nestedif and Elseif Ladder

C program

Uploaded by

raagavi109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <stdio.

h>
int main()
{
int age;

printf("Please Enter Your Age Here:\n");


scanf("%d",&age);

if ( age < 18 )
{
printf("You are Minor.\n");
printf("Not Eligible to Work");
}
else
{

if (age >= 18 && age <= 60 )


{
printf("You are Eligible to Work \n");
printf("Please fill in your details and apply\n");
}
else
{
printf("You are too old to work as per the Government rules\n");
printf("Please Collect your pension! \n");
}
}

return 0;
}

__________________________________________________________________________________
#include<stdio.h>

int main()
{
int num1, num2, num3;
printf("Enter three numbers:\n");
scanf("%d%d%d",&num1, &num2, &num3);
if(num1>num2)
{
/* This is nested if-else */
if(num1>num3)
{
printf("Largest = %d", num1);
}
else
{
printf("Largest = %d", num3);
}
}
else
{
/* This is nested if-else */
if(num2>num3)
{
printf("Largest = %d", num2);
}
else
{
printf("Largest = %d", num3);
}
}
return(0);
}

#include <stdio.h>
int main()
{
int i = 20;
if (i == 10)
{
printf("i is 10");
}
else if (i == 15)
{
printf("i is 15");
}
else if (i == 20)
{
printf("i is 20");
}
else
{
printf("i is not present");
}
}

Else if ladder programs

#include <stdio.h>
int main()
{
int marks;
printf("Please enter your marks: ");
scanf("%d", &marks);
if (marks >= 90)
{
printf("Grade is: A\n");
}
else if (marks >= 80)
{
printf("Grade is: B\n");
}
else if (marks >= 70)
{
printf("Grade is: C\n");
}
else if (marks >= 60)
{
printf("Grade is: D\n");
}
else
{
printf("Grade is: F\n");
}
}

#include<stdio.h>
int main()
{
int day;
printf("Enter day number: ");
scanf("%d", &day);
if(day==1)
{
printf("SUNDAY.");
}
else if(day==2)
{
printf("MONDAY.");
}
else if(day==3)
{
printf("TUESDAY.");
}
else if(day==4)
{
printf("WEDNESDAY.");
}
else if(day==5)
{
printf("THURSDAY.");
}
else if(day==6)
{
printf("FRIDAY.");
}
else if(day==7)
{
printf("SATURDAY.");
}
else
{
printf("INVALID DAY.");
}
return(0);
}

You might also like