Write a program in c to print
1
121
12321
1234321
123454321
Answer Posted / sahil and dipanshu
#include<stdio.h>
#include<iostream.h>
int main()
{
int i,j,k,num;
num=5;
for(i=1;i<=num;i++)
{
for(j=1;j<num-i;j++)
{
cout<<" ";
}
for(k=1;k<=i;k++)
{
cout<<k;
}
for(k=i;k>1;k--)
{
cout<<k-1;
}
cout<<endl;
}
return 0;
}
Is This Answer Correct ? | 21 Yes | 8 No |
Post New Answer View All Answers
Is it possible to use curly brackets ({}) to enclose single line code in c program?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
What are the types of functions in c?
What is c method?
Which type of language is c?
What is structure and union in c?
Describe explain how arrays can be passed to a user defined function
can any one tel me wt is the question pattern for NIC exam
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Can stdout be forced to print somewhere other than the screen?
What does 4d mean in c?
Explain how can I open a file so that other programs can update it at the same time?
What is the meaning of 2d in c?
How do we open a binary file in Read/Write mode in C?
Does sprintf put null character?