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


Please Help Members By Posting Answers For Below Questions

What are the types of functions in c?

558


Are bit fields portable?

666


What is scope rule in c?

593


What is a const pointer in c?

656


What are the properties of union in c?

577






What is character set?

675


How main function is called in c?

616


What are all different types of pointers in c?

566


How can I send mail from within a c program?

569


What does %c mean in c?

637


How pointers are declared?

552


What oops means?

570


What is the scope of static variables in c language?

620


What does p mean in physics?

575


What is merge sort in c?

632