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 the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What is C language ?
What is sizeof array?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
How do you print an address?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is call by reference in functions?
What is the use of static variable in c?
What is static function in c?
What is the difference between if else and switchstatement
Are the variables argc and argv are always local to main?
What is array of structure in c programming?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What is the heap in c?
What is huge pointer in c?