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
Define the scope of static variables.
What does the format %10.2 mean when included in a printf statement?
Explain what does the format %10.2 mean when included in a printf statement?
What are the three constants used in c?
What is meant by high-order and low-order bytes?
What does the error 'Null Pointer Assignment' mean and what causes this error?
How do you override a defined macro?
How does placing some code lines between the comment symbol help in debugging the code?
What is the difference between a free-standing and a hosted environment?
what is the basis for selection of arrays or pointers as data structure in a program
Is c compiled or interpreted?
Explain the difference between null pointer and void pointer.
What are the rules for identifiers in c?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
Describe wild pointers in c?