Hey guys! I really need help on this question! I've been stuck on this problem for a week >.< Here it goes:
Write a program that reads integers until end-of-file and then prints YES if the numbers do not decrease at all and NO otherwise. (eg: 1, 2, 3 gives YES | 1, 0, 3 gives NO)
I havent even made it to the compiler yet coz I can't even get the code to make sense to myself >.
#include
main()
{
int a, b;
FILE *fin;
fin=fopen("filein.dat", "r");
fscanf(fin, "%d", &a);
fscanf(fin, "%d", &b);
while( fscanf(fin, "%d", &a) !=EOF) {
while(a
fscanf(fin, "%d", &a);
fscanf(fin, "%d", &b);
}
printf("NO\n");
}
which is obviously horribly horribly wrong. I'm only in my 2nd week in this programming module so I'm completely noobish =X Can someone please teach me? Thanks!
Oh, and please don't use any complicated codings coz my tutor won't believe I know all that =x
2007-08-23
04:08:20
·
2 answers
·
asked by
axeile
2