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..
Daita
0
Newbie Poster
Recommended Answers
Jump to Postenclose within CODE tag
Jump to PostDid 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 …
Jump to PostSorry, I can't see your screen from here. It might be nice to let us know what errors -- or should we guess?
Jump to PostOK, now maybe you can tell us what lines the errors are on.
:icon_rolleyes:
All 14 Replies
Shankye
36
Junior Poster
Daita
0
Newbie Poster
Shankye
36
Junior Poster
Daita
0
Newbie Poster
Daita
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Daita
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Daita
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Shankye
36
Junior Poster
Trentacle
112
Junior Poster in Training
Shankye
36
Junior Poster
Daita
0
Newbie Poster
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.