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
What do you understand by normalization of pointers?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
In a switch statement, explain what will happen if a break statement is omitted?
Explain what is wrong with this program statement?
What are different storage class specifiers in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
Is that possible to store 32768 in an int data type variable?
Explain what is meant by high-order and low-order bytes?
What are runtime error?
How do you write a program which produces its own source code as output?
Is Exception handling possible in c language?
What is a scope resolution operator in c?
How can I direct output to the printer?
Does c have circular shift operators?
In a switch statement, what will happen if a break statement is omitted?