Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello guys I am new in programming so, I need help in this program.
The following output must be shown.

5
44
333
2222
11111
Posted
Updated 27-Nov-15 23:29pm
v2
Comments
Mehdi Gholam 28-Nov-15 5:44am    
... by what rules?
Patrice T 28-Nov-15 6:06am    
It is your HomeWork.
phil.o 1-Dec-15 7:59am    
You may counfound 'getting help' with 'having your work done by someone else' :)

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
How about writing the five lines individually? E.g. by means of
C++
std::cout << "..." << std::endl;
Cheers
Andi
 
Share this answer
 
Comments
[no name] 28-Nov-15 7:17am    
It does not work! It shows only one line:

...

and disappears more or less immediately.

;)
Andreas Gieriet 28-Nov-15 7:21am    
Have you changed your identity? 0x01AA <-> Member 12172345? :-D
On topic: In VisualStudio: run it in the debugger and add a breakpoint at the end of the main function. Or run it without debugger and it will show the console and ask for a key press to close the console. Or run it after compiling from a command prompt (cmd.exe).
Regards
Andi
This is one of the most powerful functions in the C language.
See Kernighan and Ritchie[^] book of Ansi C.
printf[^]
Learn to use it, and you will be a a happier programmer.
The other one is scanf.
 
Share this answer
 
First you need to try what are the requirements and how you can solve the problem? Try to figure out the steps you may use. then it will be easy to solve the problem.
This problem is also a vary simple one. Just need to think about how its working.
Run 2 for loops.say i and j.

First: Run loop i from 5 to 1. check i>=1
Second: Run loop j from 5 to 1. check j>=i
Third: print the value of i.

C++
for(int i=5; i>=1; i--){
   for(int j=5; j>=i; j--){
       printf("%d",i);
   }
   printf("\n");
}
 
Share this answer
 
Comments
Richard MacCutchan 1-Dec-15 9:05am    
You do not help people by doing their homework for them.
enhzflep 1-Dec-15 9:56am    
I'm continually surprised by people's inability to see the parallels between physical and mental exercise.
I mean, who in their right mind would wish to become more fit and think that asking someone else to run around the block would be of any use at all?
Richard MacCutchan 1-Dec-15 10:27am    
Brilliant suggestion, I might try that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900