Help me with printing these patterns in C:
*****
****
***
**
*
And one more:
1
2 2
3 3 3
4 4 4 4
Please give source code or logic.
I want thesse in the same pattern i showed plz.
C pattern printing?
#include %26lt;stdio.h%26gt;
int main (void)
{
int i, j;
for (i = 5; i %26gt; 0; i--)
{
for (j = i; j %26gt; 0; j--)
printf ("*");
printf ("\n");
}
return 0;
}
_____
#include %26lt;stdio.h%26gt;
int main (void)
{
int i, j;
for (i = 1; i %26lt;= 5; i++)
{
for (j = 1; j %26lt;= i; j++)
printf ("%d ", i);
printf ("\n");
}
return 0;
}
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int i,j;
clrscr();
for(i=5;i%26gt;0;i--)
{
for(j=0;j%26lt;i;j++)
printf("*");
printf("\n");
}
getch();
return 0;
}
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int i,j;
clrscr();
for(i=1;i%26lt;=4;i++)
{
for(j=0;j%26lt;i;j++)
printf("%d",i);
printf("\n");
}
getch();
return 0;
}
Reply:void main() {
int i=0;
int j=0;
int rows = 5;
for(i=0;i%26lt;rows;i++) {
for(j=0;j%26lt;(rows-i);j++) {
printf("*");
}
printf("\n");
}
for(i=0;i%26lt;rows;i++) {
for(j=0;j%26lt;i;j++) {
printf(i);
}
printf("\n");
}
}
survey results
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment