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

Answer Posted / sabby

#include<stdio.h>
main()
{
int i,j,s,n;
printf("Enter the number of rows:");
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
for(s=1;s<=n-i;s++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
j=j-2;
for(;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}

Is This Answer Correct ?    16 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you print an address?

716


What does sizeof function do?

602


Why & is used in scanf in c?

602


What does a function declared as pascal do differently?

595


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1499






Calculate 1*2*3*____*n using recursive function??

1503


When is a “switch” statement preferable over an “if” statement?

631


Explain the priority queues?

606


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1774


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

550


Differentiate between functions getch() and getche().

608


What happens if header file is included twice?

635


Can true be a variable name in c?

547


How many loops are there in c?

567


What are the primitive data types in c?

559