944,121 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2338
  • C RSS
Oct 11th, 2006
0

Pyramid...questioN??

Expand Post »
Here's my Prog...i dunno how 2 convert it...pls check..
its a pyramid...

#
  1.  
  2. #include<stdio.h>
  3. main()
  4. { int a, b, c, d=0;
  5. clrscr();
  6. printf("Enter a No:");
  7. scanf("%d",&c);
  8. for(a=1;a<=c;a++)
  9. { for(b=1;b<=c*2-1;b++)
  10. if (b<=c+d&&b>=c-d)
  11. printf("*");
  12. else
  13. printf(" ");
  14. printf("\n");
  15. d++;
  16. }
  17. getch();
  18. }

is my program correct?
the output must be..a pyramid
Last edited by darkeinjel04; Oct 11th, 2006 at 5:22 am.
Similar Threads
Reputation Points: 18
Solved Threads: 0
Newbie Poster
darkeinjel04 is offline Offline
13 posts
since Sep 2006
Oct 11th, 2006
0

Re: Pyramid...questioN??

Here's my Prog...i dunno how 2 convert it...pls check..
its a pyramid...

#
  1.  
  2. #include<stdio.h>
  3. main()
  4. { int a, b, c, d=0;
  5. clrscr();
  6. printf("Enter a No:");
  7. scanf("%d",&c);
  8. for(a=1;a<=c;a++)
  9. { for(b=1;b<=c*2-1;b++)
  10. if (b<=c+d&&b>=c-d)
  11. printf("*");
  12. else
  13. printf(" ");
  14. printf("\n");
  15. d++;
  16. }
  17. getch();
  18. }

is my program correct?
the output must be..a pyramid
Use int main. Its seams ok to me but I dont like non standard functions like clrscr() and getch.
Reputation Points: 251
Solved Threads: 29
Posting Whiz in Training
andor is offline Offline
274 posts
since Jun 2005
Oct 11th, 2006
0

Re: Pyramid...questioN??

well, if you run it, it shows: a Pyramid :eek:

so I guess it works

But use int main()
Do't use clrscr() and getch()

edit:

Brilliant minds think alike
Last edited by Nick Evan; Oct 11th, 2006 at 5:56 am.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Oct 11th, 2006
0

Re: Pyramid...questioN??

can anyone help me to make a program that would output a pascal triangle...???????
thanx..
Reputation Points: 18
Solved Threads: 0
Newbie Poster
darkeinjel04 is offline Offline
13 posts
since Sep 2006
Oct 11th, 2006
0

Re: Pyramid...questioN??

Here's my Prog...i dunno how 2 convert it...pls check..
its a pyramid...

#
  1.  
  2. #include<stdio.h>
  3. main()
  4. { int a, b, c, d=0;
  5. clrscr();
  6. printf("Enter a No:");
  7. scanf("%d",&c);
  8. for(a=1;a<=c;a++)
  9. { for(b=1;b<=c*2-1;b++)
  10. if (b<=c+d&&b>=c-d)
  11. printf("*");
  12. else
  13. printf(" ");
  14. printf("\n");
  15. d++;
  16. }
  17. getch();
  18. }

is my program correct?
the output must be..a pyramid

Hmmm....yeah, im only asking bcoz my TC is not workign at our house...still thanks for ur advice, i also tried the program..and it work..i only nid the pascal triangle...i've made a program but seems there is a declaration syntax, i can't figure it out what's wrong pls help..
Reputation Points: 18
Solved Threads: 0
Newbie Poster
darkeinjel04 is offline Offline
13 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Read Line from serial port buffer
Next Thread in C Forum Timeline: Things I don't understand about C programming -_-





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC