Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain the Difference between the New and Malloc keyword.

1079


i want to know the procedure of qualcomm for getting a job through offcampus

2409


What are the advantages and disadvantages of c language?

962


In which header file is the null macro defined?

1302


Hai what is the different types of versions and their differences

1897


Why C language is a procedural language?

976


Is sizeof a keyword in c?

918


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?

1199


Can you please explain the scope of static variables?

998


How does sizeof know array size?

1071


Write a program to find the biggest number of three numbers in c?

1005


cavium networks written test pattern ..

4027


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

990


What are the benefits of organizational structure?

973


Can you please explain the difference between malloc() and calloc() function?

1050