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
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
Can two or more operators such as and be combined in a single line of program code?
What is the c language function prototype?
Difference between goto, long jmp() and setjmp()?
What is the value of c?
What are the different types of control structures?
what are # pragma staments?
Where are local variables stored in c?
What are qualifiers in c?
What is indirection? How many levels of pointers can you have?
What does the c preprocessor do?
What are the difference between a free-standing and a hosted environment?
What is sizeof int?
Is c is a middle level language?