need c program

Status
Not open for further replies.

VINSTAR

Not fresh
i need c program for the following questions

Generate the following pattern using nested loops:

1

23

345

4567

56789

678901

7890123

89012345

901234567



Generate the following pyramid of digits using nested loops

. 1
.
. 2 3 2
.
. 3 4 5 4 3
.
. 4 5 6 7 6 5 4
.
. 5 6 7 8 9 8 7 6 5
.
. 6 7 8 9 0 1 0 9 8 7 6
.
. 7 8 9 0 1 2 3 2 1 0 9 8 7
.
. 8 9 0 1 2 3 4 5 4 3 2 1 0 9 8
.
. 9 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0 9
.
. 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0
 

maddy_35420

Right off the assembly line
#include<stdio.h>
#include<conio.h>
main()
{int i,j;
for(i=1;i<=10;i++)
{for(j=i;j<=2*i-1;j++)
printf("%d ",j%10);
for(j-=2;j>=i;j--)
printf("%d ",j%10);
printf("\n");
}
getch();
return 0;
}

#include<stdio.h>
#include<conio.h>
main()
{int i,j;
for(i=0;i<9;i++)
{for(j=i+1;j<=2*i+1;j++)
printf("%d ",j%10);
printf("\n");
}
getch();
return 0;
}
//this's for da 1st 1 ... the above 1's 4 da second!.. try doin ur home work yourself!!!
 
Last edited:
Status
Not open for further replies.
Top Bottom