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

write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2073


What are linked lists in c?

749


What are qualifiers?

694


difference between native and cross compilers

1761


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

701






Why do we use int main?

713


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

1717


explain what are actual arguments?

738


What is meant by preprocessor in c?

633


Write a program which returns the first non repetitive character in the string?

690


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

748


Explain union. What are its advantages?

704


can we implement multi-threads in c.

764


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

1947


What are lookup tables in c?

648