Hello all, pls guide me how to write a C-program to generate the following output:
*
**
***
****
*****
|
Go4Expert Member
|
|
| 23Aug2010,13:26 | #2 |
|
sorry y aar....I want it typed from right to left....
* ** *** **** ***** |
|
Go4Expert Member
|
|
| 23Aug2010,13:27 | #3 |
|
again same thing...how to delete a post???
|
|
Ambitious contributor
|
|
| 24Aug2010,01:49 | #4 |
|
So what have you tried? Post the code that is causing you the problems. Also post any error messages you receive from compiling your code.
Jim |
|
Pro contributor
|
![]() |
| 24Aug2010,02:49 | #5 |
|
do you mean like this?
Quote:
|
|
Go4Expert Member
|
|
| 24Aug2010,09:33 | #6 |
|
@ Virxen
Yes u have got dat diagram right. @Jim & @ Virxen I am not being able to write a program in C dat will give me the output (as Virxen's diagram). |
|
Pro contributor
|
![]() |
| 24Aug2010,13:24 | #7 |
|
hints
========= -your output must have 5 lines (maybe a for from 1 to 5?) -the first time you print 4 spaces and one star=5 characters (maybe a second or third for?) ..... the fifth time no spaces and 5 stars=5 characters start writing code and post your attempts here to help you. |
|
Mentor
|
![]() |
| 24Aug2010,13:32 | #8 |
|
Here's one that will do the trick:
Code:
void test29()
{
char *ch=" ****************";
for (int i=1; i<ch[0]; i++)
{
for (int j=ch[0]/2; j; j>>=1)
{
putchar(ch[i&j]);
}
i<<=putchar('\n')/'\n';
}
}
shabbir
like this
|
|
Go4Expert Member
|
|
| 24Aug2010,22:40 | #9 |
|
#include<stdio.h>
#include<conio.h> void main() { int i,j,k; clrscr(); for(i=1;i<=5;i++) { for(j=5-i;j>=1;j--) printf(" "); for(k=1;k<=i;k++) printf("*"); printf("\n"); } getch(); } |
|
Go4Expert Member
|
|
| 24Aug2010,22:43 | #10 |
|
I am absolutely new to C-programming. Just started with for-loop
|


