JatinHemant
asked on
C Lanugage Programme Coding for Creating Pyramid
Hi friends !
Long before 5 years, I used to make some basic and intermediate programmes using C language. But after that, I switched to Computer Networks, so I never used 'C' again.
Now, I am doing my M.Sc. and I want to be proficient in 'C' at least for my examination purpose. I want to make a programme to create a star pyramid. What will be the coding ?
As, I told you, I have previous knowledge, so I can understand the commands.
If you can also give me a website address from where, I can get some programme codings, then it will be nice of you.
Regards,
Hemant
Long before 5 years, I used to make some basic and intermediate programmes using C language. But after that, I switched to Computer Networks, so I never used 'C' again.
Now, I am doing my M.Sc. and I want to be proficient in 'C' at least for my examination purpose. I want to make a programme to create a star pyramid. What will be the coding ?
As, I told you, I have previous knowledge, so I can understand the commands.
If you can also give me a website address from where, I can get some programme codings, then it will be nice of you.
Regards,
Hemant
http://www.dreamincode.net/forums/showtopic19349.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yuy2002: Unless author posts his code, we should not. this is followd strictly by EE.
>> I want to make a programme to create a star pyramid. What will be the coding ?
You want to figure out what the structure of a pyramid is (it's pretty basic), and find the logic in it. Then all you have to do is have a nested loop that prints *'s and spaces depending on where in the pyramid you are.
It's not very complicated, so just give it a try, and post what you have here.
You'll need printf for output ;)
You want to figure out what the structure of a pyramid is (it's pretty basic), and find the logic in it. Then all you have to do is have a nested loop that prints *'s and spaces depending on where in the pyramid you are.
It's not very complicated, so just give it a try, and post what you have here.
You'll need printf for output ;)
>>yuy2002: Unless author posts his code, we should not. this is followd strictly by EE.
got it.
got it.
ASKER
Hi friends !
I used this code with some exercise and now it is OK. Please see what code, I used and if any suggestions to make it short or better, please give your kind suggestions.
The code is here:
************************** ********** ********** ********** ********** ********** ********** ********** ********** ********** **********
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0;
int j=0;
int n;
int cpos, rpos;
cpos=39;
rpos=5;
clrscr();
printf("Enter the number: ");
scanf("%d", &n);
for (i=0; i<=n; i++)
{
gotoxy(cpos, rpos);
for (j=1; j<=i*2-1; j++)
{
printf("*");
}
rpos=rpos+1;
cpos=cpos-1;
}
getch();
}
************************** ********** ********** ********** ********** ********** ********** ********** ********** ********** **********
Regards,
Hemant
I used this code with some exercise and now it is OK. Please see what code, I used and if any suggestions to make it short or better, please give your kind suggestions.
The code is here:
**************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0;
int j=0;
int n;
int cpos, rpos;
cpos=39;
rpos=5;
clrscr();
printf("Enter the number: ");
scanf("%d", &n);
for (i=0; i<=n; i++)
{
gotoxy(cpos, rpos);
for (j=1; j<=i*2-1; j++)
{
printf("*");
}
rpos=rpos+1;
cpos=cpos-1;
}
getch();
}
**************************
Regards,
Hemant
Are you sure you were allowed to use gotoxy for this ?
ASKER
Yes, I used gotoxy and it worked. There is no problem in program execution.
Regards,
Hemant
Regards,
Hemant
"allowed" as in "allowed for the assignment".