hi guys, I'm new to C language and am currently using an online tutorial, ive been doing prety well on my own until now.

Basicly the problem is with the "while" command, when i copy and paste the code im working with from the tutorial site into a word pad document and save and compile it, it works fine, however when i replicate it for training purposes i always get the same 2 compile errors saying the "while" command has no effect in the main() command.

Heres my codings.

#include <stdio.h>

	main()

	{

		int below, number;

		number = 0;
		while( number<= 0 ); {
			printf("type a number to come backwards\n");
			scanf("%d", &number);
			if( number <= 0 )
			printf("number must be positive fool");

		}

		while( number != 0 );

		{

			below = number % 10;
			printf("your number is now %d", below);
			number = number / 10;

		}

		printf("\n");

	}

and heres there coding with a link to the site at the bottom.

#include <stdio.h>

	main()  
        {
                int  value, r_digit;

		value = 0;
		while( value <= 0 ) {
	                printf("Enter the number to be reversed.\n");
	                scanf("%d", &value);
			if( value <= 0 )
				printf("The number must be positive\n");
		}

		while( value != 0 )
                {
                        r_digit = value % 10;
                        printf("%d", r_digit);
                        value = value / 10;
                }
                printf("\n");
        }

http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_023.htm

apart from the int names and text within printf argument everything else seems to be the same ( to me atleast )

any feedback would be a big help. thx.

You don't want a semicolon after a while loop:

while( number<= 0 ); {

->

while( number<= 0 ) {

lol thx very much

hmmm now it is saying that "printf" and "scanf" are undefined functions in lines 10/11.
the other code compiles fine though.

thanks again. :P

hmmm now it is saying that "printf" and "scanf" are undefined functions in lines 10/11.
the other code compiles fine though.
thanks again. :P

It is always best if you post a copy of the actual error given to you by the compiling/linking process. Paraphrasing errors and warning messages, frequently leads to guessing work and misunderstanding.
Also, it is appropriated to repost any changes made to the code, even if you have posted a previous version before.

ok my bad, the current code is;

#include <stdio.h>
	main()

	{

		int below, number;

		number = 0;
		while( number<= 0 ) {
			printf("type a number to come backwards\n");
			scanf("%d", &number);
			if( number <= 0 )
			printf("number must be possative fool");

		}

		while( number != 0 )

		{

			below = number % 10;
			printf("your number is now %d", below);
			number = number / 10;

		}

		printf("\n");

	}

and the error is:
Error E2268 wieghtconversion.cpp 10: Call to undefined function 'printf' in function main()
Error E2268 wieghtconversion.cpp 11: Call to undefined function 'scanf' in function main()

>wieghtconversion.cpp 10
You are compiling it as a C++ program. It should be compiled as wieghtconversion.c

[Edit:] change the [\code] to
[/code] to show properly formatted.

c having several commands by using those commands we have to write programes very easily in some times the c commands are doesnot work properly at that time we have to use decission making statments.
===========================================================
lux

SNIP

c having several commands by using those commands we have to write programes very easily in some times the c commands are doesnot work properly at that time we have to use decission making statments.
===========================================================
lux

www.sofrware.com

What commands? When it does not work?

hi guys, I'm new to C language and am currently using an online tutorial, ive been doing prety well on my own until now.

Basicly the problem is with the "while" command, when i copy and paste the code im working with from the tutorial site into a word pad document and save and compile it, it works fine, however when i replicate it for training purposes i always get the same 2 compile errors saying the "while" command has no effect in the main() command.

Heres my codings.

#include <stdio.h>

	main()

	{

		int below, number;

		number = 0;
		while( number<= 0 ); {
			printf("type a number to come backwards\n");
			scanf("%d", &number);
			if( number <= 0 )
			printf("number must be positive fool");

		}

		while( number != 0 );

		{

			below = number % 10;
			printf("your number is now %d", below);
			number = number / 10;

		}

		printf("\n");

	}

and heres there coding with a link to the site at the bottom.

#include <stdio.h>

	main()  
        {
                int  value, r_digit;

		value = 0;
		while( value <= 0 ) {
	                printf("Enter the number to be reversed.\n");
	                scanf("%d", &value);
			if( value <= 0 )
				printf("The number must be positive\n");
		}

		while( value != 0 )
                {
                        r_digit = value % 10;
                        printf("%d", r_digit);
                        value = value / 10;
                }
                printf("\n");
        }

http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_023.htm

apart from the int names and text within printf argument everything else seems to be the same ( to me atleast )

any feedback would be a big help. thx.

please remove the semi-colon after while in your code.
parag thx

>please remove the semi-colon after while in your code.
So you don't think that's the problem?

while( number<= 0 ); {
while( number != 0 );
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.