Q. Write a program to generate a following numbers triangle:(Where user entered number through keyboard, for example if num=5)
54321
4321
321
21
1
Ans.
/*c program for number triangle pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(; num>=1; num--)
{
for(c=num; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
getch();
return 0;
}
/*************OUTPUT****************
Enter loop repeat number(rows): 5
************************************/
/*************OUTPUT****************
Enter loop repeat number(rows): 5
54321
4321
321
21
1
************************************/
please write program for ...
ReplyDeleteABCD
BCDA
CDAB
DABC
Your required program source code at:
Deletehttp://www.cprogrammingcodes.blogspot.in/2012/12/character-rectangle-program.html
Please can you try for this .....
ReplyDeleteinput :abcd
output:
a a a a a a a a a
a b b b b b b b a
a b c c c c c b a
a b c d d d c b a
a b c d d c b a
a b c d d d c b a
a b c c c c c b a
a b b b b b b b a
a a a a a a a a a
10 9 8 7 6 5 4 3 2 1 0
ReplyDelete10 9 8 7 5 3 2 1 0
10 9 8 5 2 1 0
10 9 5 1 0
10 5 0
5
can anyone help ?
8765
ReplyDelete765
65
5
please reply me
I want the same program by using while loop
ReplyDeleteAbove number triangle pyramid using while loop source code as:
Delete#include"stdio.h"
#include"conio.h"
int main()
{
int num,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
while(num>=1)
{
c=num;
while(c>=1)
{
printf("%d",c);
c--;
}
num--;
printf("\n");
}
getch();
return 0;
}