Q. Write a C program to print the following number structure:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
Ans.
/*c program for print the following number triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
int r,c,sp,n=6;
for(r=1; r<=6; r++)
{
for(sp=1; sp<=n; sp++)
printf(" ");
for(c=1; c<=r; c++)
{
printf("%d",r);
printf(" ");
}
printf("\n");
n=n-1;
}
getch();
return 0;
}
/************Output************/
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
Ans.
/*c program for print the following number triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
int r,c,sp,n=6;
for(r=1; r<=6; r++)
{
for(sp=1; sp<=n; sp++)
printf(" ");
for(c=1; c<=r; c++)
{
printf("%d",r);
printf(" ");
}
printf("\n");
n=n-1;
}
getch();
return 0;
}
/************Output************/
Screen shot for number triangle C program |
wrong program:(
ReplyDeletewhat is wrong in above program?
DeleteThis program is executed successfully and produced output.
plz tell the algorithm formed in this pyramid
ReplyDelete*
* *
* * *
* * * *
Algorithm and program for above star pyramid at:
Deletehttp://cprogrammingcodes.blogspot.in/2012/10/algorithm-for-star-pyramid.html
please
ReplyDelete*
**
***
****
*****
******
@Ahmed,
DeleteYour required above program source code at:
http://cprogrammingcodes.blogspot.in/2013/04/star-sequence-pyramid.html
write a program to get o/p in this format
ReplyDelete0 4 4 4 4 4
1 1 3 3 3 3
2 2 2 2 2 2
3 3 3 3 1 1
4 4 4 4 4 0
this program is not executing :(
ReplyDeletei want make this program in c++
ReplyDelete011235813...............
means addition all time when we add 1 1 it becomes 2 when we add 3 in it will become 8 when we add 5 or 8 it will 13 to 100.please help me
The series which you want is called Fibonacci Series and flowchart for this is given at : http://cprogrammingcodes.blogspot.in/2012/11/flowchart-for-fibonacci-series.html
DeleteThe program is given at http://cprogrammingcodes.blogspot.in/2011/09/fibonacy-series-c-program.html
and program using recursion is at :
http://cprogrammingcodes.blogspot.in/2012/08/generate-fibonacci-series-using.html
How about this pattern??
ReplyDelete4
4 3 4
4 3 2 3 4
4 3 2 1 2 3 4
4 3 2 3 4
4 3 4
4
pls.. answer this As soon as possible.. thank you.. :)
Write a C program to find the value of sin (x) using the series..
ReplyDeleteup to N terms accuracy without using the user defined function of sin(x).
output:
Enter value of x (in degress): 45
Enter number of terms (N): 6
The value of sin 45 with 6 terms accuracy is equal to 0.707.
Write a C program to find the value of cos (x) using the series
⋯ ⋯ up
to N terms accuracy without using the user defined function of cos(x).
output:
Enter value of x (in degress): 30
Enter number of terms (N): 6
The value of cos 30 with 5 terms accuracy is equal to 0.866.
help me pls...