Write a c program to sort six numbers and find the largest
one by using the ladder of if-else?


plz do help me

Answers were Sorted based on User's Feedback



Write a c program to sort six numbers and find the largest one by using the ladder of if-else? ..

Answer / sandeep kumar yadav. by m.c.a

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,max;
clrscr();
printf("Enter the six Number \n");
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
if(a>b && a>c && a>d && a>e && a>f)
max=a;
else if(b>a && b>c && b>d && b>e && b>f)
max=b;
else if(c>a && c>b && c>d && c>e && c>f)
max=c;
else if(d>a && d>b && d>c && d>e && d>f)
max=d;
else if(e>a && e>b && e>c && e>d && e>f)
max=e;
else if(f>a && f>b && f>c && f>d && f>e)
max=f;
printf("\n\n Maximum Number is = %d",max);
getch();
}

Is This Answer Correct ?    35 Yes 9 No

Write a c program to sort six numbers and find the largest one by using the ladder of if-else? ..

Answer / jugal k. sewag

#include<stdio.h>
#include<conio.h>

void main(){

int a,b,c,d,e,f;
int max;
clrscr();

printf("Enter any six numbers: ");
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

if(a>=b && a>=c && a>=d && a>=e && a>=f)
max =a;
else if(b>=c && b>=d && b>=e && b>=f)
max=b;
else if(c>=d && c>=e && c>=f)
max=c;
else if(d>=e && d>=f)
max=d;
else if(e>=f)
max=e;
else
max=f;

printf("Max among six number is: %d",max);

getch();

}

Is This Answer Correct ?    14 Yes 12 No

Post New Answer

More C Interview Questions

. Write a program to get a string and to convert the 1st letter of it to uppercase

2 Answers   HTC,


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

0 Answers  


write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?

3 Answers   Mind Tree,


What is getche() function?

0 Answers  


How to find a missed value, if you want to store 100 values in a 99 sized array?

0 Answers   Honeywell, Zomato,






How do you print an address?

0 Answers   TCS,


Why does everyone say not to use gets?

0 Answers  


Explain what is the difference between far and near ?

0 Answers  


Explain what is the difference between functions getch() and getche()?

0 Answers  


Is main is a keyword in c?

0 Answers  


what is C?

9 Answers   Syntel,


atoi, which takes a string and converts it to an integer. write a program that reads lines(using getline), converts each line to an integer using atoi and computes the average of all the numbers read. also compute the standard deviation

0 Answers  


Categories