954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pyramid...questioN??

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

#

#include<stdio.h>
main()
{ int a, b, c, d=0;
   clrscr();
   printf("Enter a No:");
   scanf("%d",&c);
   for(a=1;a<=c;a++)
   { for(b=1;b<=c*2-1;b++)
    if (b<=c+d&&b>=c-d)
    printf("*");
    else 
    printf(" ");
    printf("\n");
    d++;
   }
   getch();
  }


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

darkeinjel04
Newbie Poster
13 posts since Sep 2006
Reputation Points: 18
Solved Threads: 0
 

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

#include<stdio.h>
main()
{ int a, b, c, d=0;
   clrscr();
   printf("Enter a No:");
   scanf("%d",&c);
   for(a=1;a<=c;a++)
   { for(b=1;b<=c*2-1;b++)
    if (b<=c+d&&b>=c-d)
    printf("*");
    else 
    printf(" ");
    printf("\n");
    d++;
   }
   getch();
  }

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.

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 

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 :P

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

can anyone help me to make a program that would output a pascal triangle...???????
thanx..

darkeinjel04
Newbie Poster
13 posts since Sep 2006
Reputation Points: 18
Solved Threads: 0
 

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

#include<stdio.h>
main()
{ int a, b, c, d=0;
   clrscr();
   printf("Enter a No:");
   scanf("%d",&c);
   for(a=1;a<=c;a++)
   { for(b=1;b<=c*2-1;b++)
    if (b<=c+d&&b>=c-d)
    printf("*");
    else 
    printf(" ");
    printf("\n");
    d++;
   }
   getch();
  }

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..

darkeinjel04
Newbie Poster
13 posts since Sep 2006
Reputation Points: 18
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You