Pyramid...questioN??

Reply

Join Date: Sep 2006
Posts: 13
Reputation: darkeinjel04 is an unknown quantity at this point 
Solved Threads: 0
darkeinjel04 darkeinjel04 is offline Offline
Newbie Poster

Pyramid...questioN??

 
0
  #1
Oct 11th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: Pyramid...questioN??

 
0
  #2
Oct 11th, 2006
Originally Posted by darkeinjel04 View 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
Use int main. Its seams ok to me but I dont like non standard functions like clrscr() and getch.
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,834
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 297
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Pyramid...questioN??

 
0
  #3
Oct 11th, 2006
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 niek_e; Oct 11th, 2006 at 5:56 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 13
Reputation: darkeinjel04 is an unknown quantity at this point 
Solved Threads: 0
darkeinjel04 darkeinjel04 is offline Offline
Newbie Poster

Re: Pyramid...questioN??

 
0
  #4
Oct 11th, 2006
can anyone help me to make a program that would output a pascal triangle...???????
thanx..
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 13
Reputation: darkeinjel04 is an unknown quantity at this point 
Solved Threads: 0
darkeinjel04 darkeinjel04 is offline Offline
Newbie Poster

Re: Pyramid...questioN??

 
0
  #5
Oct 11th, 2006
Originally Posted by darkeinjel04 View 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

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..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC