As MacGyver mentioned, do not use void main(), use int main(). On a newer version of the C Standard, you should be able to get away with int main() without return 0, but I would rather leave the return 0 there anyway, at least for C.It worked.. but they did not tell us about return 0 as well as of yet so i modified it like the following
clrscr() and getch() are both non-standard and your program does not need them, as far as I can tell.
Is this in school? If not, I suggest that you quit and demand your money back. They are hopeless in teaching C, and probably in writing C as well.they also didnt teach us anything about libraries like include etc so thats why
No 1234 is an integer, not four integers.because 1234 shoud be inteegers
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
well our teacher said to use void main as it will eliminate many errors etc but ok i'll be using int main as well thanks... and return 0 maybe they will tell us about it later, as they have not as of yet..
yes this is in college.. not in some other institution hehe :P
clrscr will clear the screen if we dont clear the screen then the old date will also flash on the screen while u running the program in the compiler and without getch the program will execute and quit directly and it wont stay on screen..
You might want to read the FAQ on main().well our teacher said to use void main as it will eliminate many errors etc but ok i'll be using int main as well thanks... and return 0 maybe they will tell us about it later, as they have not as of yet..
If you do want to use them, you should include the relevant header. Chances are it is <conio.h>, but this being non-standard, there is no guarantee that this is the case, and these functions may not even be available. You can roughly simulate getch() using the standard function getchar() from <stdio.h>, but there is no portable and standard way of clearing the screen.clrscr will clear the screen if we dont clear the screen then the old date will also flash on the screen while u running the program in the compiler and without getch the program will execute and quit directly and it wont stay on screen..
Out of curiosity, what compiler (and IDE) are you using?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
> well our teacher said to use void main as it will eliminate many errors
Really?! Like what?
Just curious. If he hasn't said anything about it then he's lying worse than most people.
Code:#include <stdio.h> int main() { long int num,i,x; i=10; printf("Enter the integer\n"); scanf("%d",&num); printf("\nEntered number is %d\n",num); while(num) { x = num; printf("%d", num % i); num /= i; } }
Read the forum rules before digging up more dead threads.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.