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

A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

752


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

723


Can two or more operators such as and be combined in a single line of program code?

923


What is the c language function prototype?

742


Difference between goto, long jmp() and setjmp()?

822






What is the value of c?

670


What are the different types of control structures?

677


what are # pragma staments?

1713


Where are local variables stored in c?

661


What are qualifiers in c?

656


What is indirection? How many levels of pointers can you have?

776


What does the c preprocessor do?

723


What are the difference between a free-standing and a hosted environment?

854


What is sizeof int?

726


Is c is a middle level language?

696