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

Answer Posted / ayas kumar das

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

Is This Answer Correct ?    12 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is = symbol different from == symbol in c programming?

615


What is the difference between char array and char pointer?

527


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

649


How to explain the final year project as a fresher please answer with sample project

472


Explain how can I pad a string to a known length?

655






Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

706


What is substring in c?

642


Why is c platform dependent?

624


Explain how can I read and write comma-delimited text?

660


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2223


Do pointers store the address of value or the actual value of a variable?

612


What kind of structure is a house?

558


which is conditional construct a) if statement b) switch statement c) while/for d) goto

740


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2037


When should a type cast be used?

576