By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

How Could I Do It???

P: 2
i dont know what kind of figure is this:
1
12
123
1234
12345
or
54321
4321
321
21
1

how could i do a c++ program of it???
Feb 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: 96
Expand|Select|Wrap|Line Numbers
  1.  #include <stdio.h> 
  2. #include <conio.h>
  3. int main()
  4. {
  5.     int i,j,k;
  6.     clrscr();
  7.     printf("Enter the No :");
  8.     scanf("%d",&k);
  9.     i=1;
  10.     j=i+1;
  11.     printf("%d\n",i);
  12.     do
  13.     {
  14.         for(i=1;i<=j;i++)
  15.         {
  16.             printf("%d",i);
  17.         }
  18.         j=i;
  19.         printf("\n");
  20.     }while(j<=k);
  21.     getch();
  22.     return 0;
  23. }
  24.  
Try this below C code...and try to do by your own for printing in reverse.....
Feb 21 '07 #2

10K+
P: 13,264
Guys let's make it a point to always post code using code tags.

@OP you will do well by attempting the problem yourself first and posting your efforts.
Feb 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.