Write a program in c to print
1
121
12321
1234321
123454321
Answer Posted / rohit1729
#include<iostream>
using namespace std;
int main()
{
int i,j,k,t,n,c,a[20];
cin>>t;
for(k=0;k<20;k++)
a[k]=(k+1);
while(t--)
{
cin>>n;
for(i=0;i<n;i++)
{
c=i-1;
for(j=0;j<(2*i+1);j++)
{
if(i>=j)
cout<<a[j];
else
{
cout<<a[c];
c--;
}
}cout<<" ";
}cout<<endl;
}
return 0;
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
When should you use a type cast?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures
Explain how can you check to see whether a symbol is defined?
Can a variable be both const and volatile?
What are preprocessor directives in c?
what are enumerations in C
Write a program to print factorial of given number without using recursion?
What is difference between constant pointer and constant variable?
What is this infamous null pointer, anyway?
What does int main () mean?
provide an example of the Group by clause, when would you use this clause
What are the Advantages of using macro
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
How can you find the exact size of a data type in c?