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


plz do help me

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the c preprocessor do?

782


Can you think of a logic behind the game minesweeper.

2140


Write a program to reverse a given number in c?

724


Explain how can I open a file so that other programs can update it at the same time?

766


what do you mean by inline function in C?

766






What is the use of pointers in C?

785


Is c pass by value or reference?

747


Do variables need to be initialized?

757


Describe the difference between = and == symbols in c programming?

957


What standard functions are available to manipulate strings?

734


What is call by reference in functions?

791


Explain what is the benefit of using const for declaring constants?

742


How does selection sort work in c?

775


What are the types of assignment statements?

771


What is the hardest programming language?

843