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
How do you print an address?
What does sizeof function do?
Why & is used in scanf in c?
What does a function declared as pascal do differently?
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?
Calculate 1*2*3*____*n using recursive function??
When is a “switch” statement preferable over an “if” statement?
Explain the priority queues?
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
Differentiate between functions getch() and getche().
What happens if header file is included twice?
Can true be a variable name in c?
How many loops are there in c?
What are the primitive data types in c?