## needhelpe -5

how can I output 123454321, if i input 5. and 1234321 if i input 4?

## Ancient Dragon 5,243

use a loop that counts from 1 to the number you enter, then another loop that counts backwards back down to 1. Print the loop counter.

## Gaiety 1

how can I output 123454321, if i input 5. and 1234321 if i input 4?

you could do that by following below

``````for(start = 1; start <= conut; start++)
putchar( start + '0' );
for(start = start -2; start > 0; start--)
putchar( start + '0' );``````

## firstPerson 761

Haven't tested it yet, but it could be similar to this :

``````int M = 5;
int i = 1;
while(i <= M) cout << i++ <<" ";  //print from 1 to 5
while(--i > 0) cout << i << " "; //print from 4 to 1``````

## needhelpe -5

you could do that by following below

``````for(start = 1; start <= conut; start++)
putchar( start + '0' );
for(start = start -2; start > 0; start--)
putchar( start + '0' );``````

this is what I have so far, but does not work:
#include <stdio.h>
int main()
{
int n
printf ("Enter digit: ");
scanf ("%d",&n);

if ((n < 0) || (n > 9))
{
printf("number not in range\n");
}

for (i = 1; i <=n; i++);
pintf("%d",count);
for(i=n; i>=1; i--);
printf(ā%dā, count);

return 0;
}

## yellowSnow 607

Ok here we go:

- you're missing the semi-colon after your declaration of the variable n.

- you haven't declared the variables i and count. And you don't need the count variable. Just print the value of i.

- remove the semi-colons from the end of your for statements - you have empty for statements here and that is why you are not getting the desired output.

- when counting back, initialize i to n-1.

- the code to print the required output should be part of an else clause - that way, if invalid data is entered, you don't end up printing erroneous values after printing your error message.

- in the future, use code tags when posting code - read the information at this link to learn how to do this:

## Ali Shah Ahmed -4

How can i print 123454321 (on input 5) in a single loop without any conditional statement...???

## WaltP 2,905

How can i print 123454321 (on input 5) in a single loop without any conditional statement...???

Is this a joke?

## Ali Shah Ahmed -4

no... m serious...!!!

## Salem 5,138

> in a single loop without any conditional statement.
But a loop without any conditional statement either runs zero times, or forever.

Anyway, here's one answer - have fun explaining it ;)
Or learn something, by trying to unravel it :)

``````#include <stdio.h>
int main ( ) {
int num = 5;
int i = 1, j = 1;
while ( i > 0 ) {
putchar(i|(0x60>>(i/i)));
i+=i/i-((i<<(i/i))/i)*(j++-num>=0);
}
return 0;
}``````

I know I did, obfuscating it :twisted:

## Ali Shah Ahmed -4

thanks dude... :)
this is really great...

commented: No problem - you didn't learn anything -4

## Rajkumar#T

``````public static void main(String a[]) {
int num = 20;
int sequence;
for (int i = 1; i < 2*num; i++) {
sequence = i>num ? 2*num - i : i;
System.out.print(sequence);
}
}``````

## Nick Evan 4,005

Good job man! After only 10 months you came up with an answer in the wrong language. :icon_wink: Closed.

commented: LOL +34