Post #7 has a solution, and if you combine that with post #8, you would have a "simpler" solution.
--
Mats
Post #7 has a solution, and if you combine that with post #8, you would have a "simpler" solution.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Code:int w,x,y,ans; printf("Enter a number: "); scanf("%d",&x); do{ for(y=1;y<=x;y++){ printf("Input number: "); scanf("%d",&w); if(w>y) ans=w; } } while(y<=x); printf("The highest number is %d.\n",ans);
just a little bit more T_T
help please
Code:BOOL isFirst; DWORD Biggest; DWORD Smallest; // get number of values N isFirst = TRUE; for(i=0;i<N;i++){ //get the input value V if(isFirst){ Biggest = V; Smallest = V; isFirst = FALSE; } else { Biggest = __max(V , Biggest); Smallest = __min(V , Smallest); } } // print out the biggest and smallest value
waaaaaaaaaaaaaaaaaa
i cant understand T_T
What part do you have trouble understanding?i cant understand T_T
In this case isFirst is clearly a boolean variable, and the variable is named isFirst, not something with so little context as x.Is never a good coding style...
To be fair, abachler's code example uses type and function names found in a library that is not part of standard C.If you can't understand such simple code, then programming may not be for you.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Last edited by abachler; 02-08-2008 at 11:02 AM.
It could be some kind of hybrid K&R and Allman, I suppose. An indenting style doesn't necessarily have to be one of the standard ones (I use a modified K&R where I indent functions the same as everything else).
Edit: Sorry, substitute Whitesmiths for Allman.
Yes, coding styles are something that you should make up yourself. However, there are still guidelines to follow or you'll make it confusing.
The least confusing style IMO is Allman. Then K&R, then the rest.
Nevertheless, that hybrid style is not a good one. Brackets should be at the same level, otherwise it's confusing to the reader.
is the program working?
i hope someone could give me a simplified program
im really slow in C programming and i am learning it here...
thanks a lot to everyone who could help me
You have not answered my question yet, namely, what part do you have trouble understanding?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
in here T_T
Code:if(isFirst){ Biggest = V; Smallest = V; isFirst = FALSE; } else { Biggest = __max(V , Biggest); Smallest = __min(V , Smallest); } }