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 display all prime numbers

0 Answers  


Which control loop is recommended if you have to execute set of statements for fixed number of times?

0 Answers  


how can be easily placed in TCS.

0 Answers   TCS,


What is the size of structure in c?

0 Answers  


what is c?

13 Answers   Tech Mahindra,


Explain what are linked list?

0 Answers  


Is malloc memset faster than calloc?

0 Answers  


what is meant by the "equivalence of pointers and arrays" in C?

3 Answers   Satyam,


What is malloc return c?

0 Answers  


Can you please explain the difference between malloc() and calloc() function?

0 Answers  


How can I write functions that take a variable number of arguments?

0 Answers  


How can I send mail from within a c program?

0 Answers  


Categories