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
Explain the Difference between the New and Malloc keyword.
i want to know the procedure of qualcomm for getting a job through offcampus
What are the advantages and disadvantages of c language?
In which header file is the null macro defined?
Hai what is the different types of versions and their differences
Why C language is a procedural language?
Is sizeof a keyword in c?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Can you please explain the scope of static variables?
How does sizeof know array size?
Write a program to find the biggest number of three numbers in c?
cavium networks written test pattern ..
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
What are the benefits of organizational structure?
Can you please explain the difference between malloc() and calloc() function?