hi all friends plz help me. i have an assingment giving by sir.

write a program that accepts three values from user and print the highest value from them?

remember: The program should be for turbo c.

Recommended Answers

So, are you having a problem? The code looks ok, functionally, although you should probably add conditions that test for equality as your code won't trigger if it finds an equality condition. IE, if (a >= b && a >= c) { if (a==b) printf(a and b > c); }, …

Jump to Post

All 2 Replies

main()

{int a,b,c;
printf("Enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
    printf("%d is greater",a);
 else if (b>a && b>c)
     printf("%d is greater",b);
 else if (c>a && c>b)
     printf("%d is greater",c);

}

So, are you having a problem? The code looks ok, functionally, although you should probably add conditions that test for equality as your code won't trigger if it finds an equality condition. IE, if (a >= b && a >= c) { if (a==b) printf(a and b > c); }, etc. It does get more complicated that that, since you also have to check for equality with c, so if a, b, and c are all equal, you might want to note that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.