Could we find the largest among three numbers using 'for' and if?
I have the following program, please check it
#include<stdio.h>
main()
{
int a,b,c,sum=o,i';
printf("enter the numbers");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
for(i=sum;i<=sum,i--)
{
if(i==a||i==b||i==c)
printf("%d the greatest");
exit();
}}........please clarify the logic if it is correct to the intention..

enclose within CODE tag

I didn't get it.........

Did you tried to compile it??

in First line only you have so many mistakes ..

sum = o

It showed be

sum = 0

remove ` after i..

Use { } correctly

and in

printf("%d blah blah");

what you are printing ????
i ?? sum ???

Make this changes compile it,
if got error copy paste that code..

#include<stdio.h>
main()
{
int a,b,c,i,sum = 0;
printf("enter the numbers");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
For(i=sum;i<=sum,i--)
if(i==a||i==b||i==c)
printf("%d",i);
exit()
}

I have compiled it.compiler is showing errors

Sorry, I can't see your screen from here. It might be nice to let us know what errors -- or should we guess?

I am sorry .The errors are...possible use of i before definition,and funtion call missing

OK, now maybe you can tell us what lines the errors are on.
:icon_rolleyes:

First one is in the column 8 and the second in the 12th

So the e in include is using i before definition and the d in stdio.h is a function call missing?

Sorry, but this is like pulling teeth. If you want help, you MUST give us all the information necessary to understand the problem. Not bits and pieces that are useless without the rest of the information.

Copy and Paste everything that will help rather than paraphrasing which leaves out important clues...

And learn to format your code

Problem with exit()

exit(0);

Use { } may take few seconds more to type but they help

Check this now

#include<stdio.h>
main()
{
int a,b,c,sum=0,i;
printf("enter the numbers");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
for(i=sum;i<=sum ;i--)
{
        if(i==a || i==b || i==c)
        {
        printf("%d the greatest",i);
        exit(0);
        }
}
}

looks so neat and easy to understand

Sorry, missed the second page. Everything I had to say has been said

Its ok friend ..

Hope your problem solved now ..

Thank you very much

Be a part of the DaniWeb community

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