#include
#define Mx 20
#define My 20
void draw(int base,int height);
int main()
{
// draw(5,4);
// draw(5,4);
// draw(15,6);
int a=2,h=0;
char c;
while(a%2==0){
printf("Enter the base:");
scanf("%d",&a);
if (a%2==0)
printf("only odd length is allowed\n");
getchar();
}
while (h==a || h<2){
printf("Enter the height :");
scanf("%d",&h);
if (h==a)
printf("\nthe height you entered makes an Equilateral triangle.\n");
if (h<2)
printf("\nheight must be greater than 1.\n");
getchar();
}
draw(a,h);
getchar();
}
void draw(int base,int height){
if(base%2==0) {
printf("The length of the base its not an odd number \n");
return ;
}
int i=0,j;
int a=i;
int b=base,t;
// (base>height)?t=base:t=height;
int howmanystars=(base)/(height-1);
float stars=height-1;
stars=(float)(base)/stars-0.5;
if (howmanystars<=stars)
howmanystars++;
int h=1;
for (i=0;i<=height;i++){
if (i==height-1)
h=base;
for (int k=0;k<=(base-h+1)/2;k++)
printf(" ");
for (j=0;j<=h;j++)
printf("*");
h=h+howmanystars;
printf("\n");
}
}
Creating Isosceles Triangle in C
Creating Isosceles Triangle
Labels:
Basics of C,
C Assignments
Subscribe to:
Post Comments (Atom)
If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE
More Useful Topics... |
|
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
}
No comments:
Post a Comment