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

Answer Posted / mohammedayub.y(c.i.e.t)

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n,k;
printf("enter the number :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=n;k>i;k--)printf(" ");
for(j=1;j<=i;j++)
{
printf("%d",j);
}
if(i>1)
{
for(j=i;j>1;j--)
{
printf("%d",j-1);
}
}
printf("\n");
}

getch();
return 0;
}

Is This Answer Correct ?    72 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is printf () in c?

570


Explain the difference between #include "..." And #include <...> In c?

610


Do you know the use of fflush() function?

588


What is a function in c?

561


Is fortran still used today?

590






Differentiate between a structure and a union.

747


write an algorithm to display a square matrix.

2207


What math functions are available for integers? For floating point?

612


How many types of errors are there in c language? Explain

560


What are data structures in c and how to use them?

662


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

553


What does p mean in physics?

575


When should I declare a function?

608


what does static variable mean?

641


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1768