Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
July 17th, 2013, 01:14 PM
 gingare
Registered User

Join Date: Jul 2013
Posts: 3
Time spent in forums: 2 h 15 m 18 sec
Reputation Power: 0
Until Number to character.Help please !

Hello everyone,i'm learning C new myself from one book and I can't write this code,please help me :S

problem : it's given to us = 2a3b4c5d

How can i do it to aabbbccccddddd ?

we must print the char next to the until number ? thank you

#2
July 17th, 2013, 02:46 PM
 salem
Contributed User

Join Date: Jun 2005
Posts: 4,264
Time spent in forums: 2 Months 4 Weeks 1 Day 17 h 18 m 9 sec
Reputation Power: 1827
Code:
```int num;
char ch;
printf("Enter it\n");
scanf("%d%c",&num,&ch);
printf("The number is %d, and the char is %c\n", num, ch );```

Now, can you
- use num to print ch a number of times?
- put a loop around the whole thing?
__________________
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

#3
July 17th, 2013, 03:39 PM
 gingare
Registered User

Join Date: Jul 2013
Posts: 3
Time spent in forums: 2 h 15 m 18 sec
Reputation Power: 0
hi again,i can't understand my friend,i can't do it :/ i'm using your code,but i don't know how can i do that.. I mean,

The problem : 2a3b4c5d(or maybe 5a3c2f6g) it's given to us.

And the desired from us : print char,until to the left number.. I mean,

2a3b4c5d = aabbbccccddddd

5a3c2f6g = aaaaacccffgggggg something like that :/

#4
July 17th, 2013, 03:47 PM
 gingare
Registered User

Join Date: Jul 2013
Posts: 3
Time spent in forums: 2 h 15 m 18 sec
Reputation Power: 0
hi again,i can't understand my friend,i can't do it :/ i'm using your code,but i don't know how can i do that.. I mean,

The problem : 2a3b4c5d(or maybe 5a3c2f6g) it's given to us.

And the desired from us : print char,until to the left number.. I mean,

2a3b4c5d = aabbbccccddddd

5a3c2f6g = aaaaacccffgggggg something like that :/

#5
July 17th, 2013, 06:54 PM
 dwise1_aol
Contributing User

Join Date: Jan 2003
Location: USA
Posts: 6,882
Time spent in forums: 3 Months 1 Day 14 h 51 m 6 sec
Reputation Power: 2199
Posting the same message twice won't get you anywhere.

You have the character and the number of times to output it. Do you know how to write a for loop?

#6
July 17th, 2013, 10:32 PM
 yashwanth.c.b
Registered User

Join Date: Jul 2013
Posts: 26
Time spent in forums: 8 h 3 m 54 sec
Reputation Power: 0
until a no.

hi.i am also a beginner.but i think i understood the problem.add the following intobyoue end of the code
Code:
`for(int i=1;i <=num;i++){printf("%s",ch);}`

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Until Number to character.Help please !