English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hints
You may nest two inner loops, one to print spaces and one to print numbers (0-9), inside an outer loop that steps down the screen from line to line.
ask user to enter any number from 0-9. if he enter 3 out put will be.
*****1
****2 2
***3 3 3
**4 4 4 4
In the above sample there will no'*' in real and it will not appear in screan . it will write only for submitting sample.if I do not write * prew of sample is not correct in appearence.
Please submit complete solution of the question.

2006-10-26 02:53:51 · 2 answers · asked by Muhammad A 1 in Education & Reference Higher Education (University +)

2 answers

Which language do you want to use?

int resp = GetUserInput();   // Validates 0-9

for (int i = 1; i <= resp; i++)
{
   for (int j = 0; j < resp - i + 2; j++)
      print(' ');
   for (int j = 0; j < i; j++)
   {
      print(i);
      print(' ');
   }
   print('\n');   // newline
}

2006-10-26 03:09:04 · answer #1 · answered by Dave 6 · 0 0

suitable formatting receives a touch more effective complicated in case you enable your list to go previous 9 (2 digit numbers, 3 digit numbers, and so on.) this job might want to be a lot less complicated in some programming languages than in others, searching on what "textual content" or string purposes are available in. if the right purposes are available in, you may want to attempt this with a unmarried loop (no nested loops required).

2016-12-05 06:11:24 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers