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

Is it possible to use curly brackets ({}) to enclose single line code in c program?

801


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

614


What are the types of functions in c?

576


What is c method?

538


Which type of language is c?

654






What is structure and union in c?

604


Describe explain how arrays can be passed to a user defined function

606


can any one tel me wt is the question pattern for NIC exam

1559


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

712


Can stdout be forced to print somewhere other than the screen?

627


What does 4d mean in c?

950


Explain how can I open a file so that other programs can update it at the same time?

594


What is the meaning of 2d in c?

615


How do we open a binary file in Read/Write mode in C?

681


Does sprintf put null character?

604