E
emmx
Hi
I am new to c. I am trying to write a simple program which will
prompt the user to enter an integer between 1 and 9 and the output
will be produced as follows (eg. 5)
1
22
333
4444
55555
I have been trying to write this with a while loop but I have gotten
stuck. I am using the book, "C how to program 4th edition", but there
is no answer for this question and there are no resources for this
edition on the dietel site.
If someone could look at the code that I have so far (it is not much -
please remember I have only been learning this a few weeks) and offer
a suggestion as to how I can get the program to print only the numbers
up to the integer entered this would be appreciated.
#include <stdio.h> /* for library function: printf */
/* function main begins program execution */
main()
{
char string[]; /* initialisation */
printf ( "Enter an integer between 1 and 9:\n" );
scanf ( "%s", string );
/* loop until user keys end-of-file sequence */
while ( string >= 1 ) && ( string <= 9);
} /* end while */
} /* end function main */
Thankyou
I am new to c. I am trying to write a simple program which will
prompt the user to enter an integer between 1 and 9 and the output
will be produced as follows (eg. 5)
1
22
333
4444
55555
I have been trying to write this with a while loop but I have gotten
stuck. I am using the book, "C how to program 4th edition", but there
is no answer for this question and there are no resources for this
edition on the dietel site.
If someone could look at the code that I have so far (it is not much -
please remember I have only been learning this a few weeks) and offer
a suggestion as to how I can get the program to print only the numbers
up to the integer entered this would be appreciated.
#include <stdio.h> /* for library function: printf */
/* function main begins program execution */
main()
{
char string[]; /* initialisation */
printf ( "Enter an integer between 1 and 9:\n" );
scanf ( "%s", string );
/* loop until user keys end-of-file sequence */
while ( string >= 1 ) && ( string <= 9);
} /* end while */
} /* end function main */
Thankyou