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
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What is c language and why we use it?
what is event driven software and what is procedural driven software?
Is c still relevant?
How do we make a global variable accessible across files? Explain the extern keyword?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Is c a great language, or what?
Explain how can I read and write comma-delimited text?
Can we use any name in place of argv and argc as command line arguments?
What is ambagious result in C? explain with an example.
How can I ensure that integer arithmetic doesnt overflow?
how we can make 3d venturing graphics on outer interface
int i=10; printf("%d %d %d", i, i=20, i);
How can I write a function that takes a format string and a variable number of arguments?
What are variables c?