Write a program in c to print
1
121
12321
1234321
123454321

Answer Posted / arun c s

#include <stdio.h>
main()
{
int i, j, k, space, n=9;

for (i=1; i<=n; i++)
{
for (j=1; j<=n-i; j++)
putchar(' ');
for (j=1,k=2*i-1; j<=2*i-1; j++,k--)
{
if (j <= k)
printf("%d", j);
else
printf("%d", k);
}
putchar('
');
}

getch();
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an identifier?

708


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


How is a macro different from a function?

744


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1596


What is the difference between fread buffer() and fwrite buffer()?

769






Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

2626


How we can insert comments in a c program?

730


What does sizeof int return?

695


Where are c variables stored in memory?

679


how to build a exercise findig min number of e heap with list imlemented?

1724


what is the structure pointer?

1728


C program to find all possible outcomes of a dice?

1945


Why do we use & in c?

678


What are the 5 elements of structure?

688


Describe dynamic data structure in c programming language?

694