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

what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2647


What is c language and why we use it?

1078


what is event driven software and what is procedural driven software?

2585


Is c still relevant?

1087


How do we make a global variable accessible across files? Explain the extern keyword?

1884


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

1148


Is c a great language, or what?

1123


Explain how can I read and write comma-delimited text?

1174


Can we use any name in place of argv and argc as command line arguments?

1077


What is ambagious result in C? explain with an example.

2638


How can I ensure that integer arithmetic doesnt overflow?

1173


how we can make 3d venturing graphics on outer interface

4834


int i=10; printf("%d %d %d", i, i=20, i);

1626


How can I write a function that takes a format string and a variable number of arguments?

1060


What are variables c?

1055