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...

print the following using nested for loop.
5 4 3 2 1
1 2 3 4
3 2 1
1 2
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5

Answer Posted / vignesh1988i

DIFFERENT LOGIC

#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,p;
printf("enter the limit value");
scanf("%d",&m);
n=m+1;
for(int i=1;i<2*m-1;i++)
{
if(i<=m)
{
n--;
p=0;
}
else
{
n++
p=1;
}
if(i%2==p)
{
for(int j=1;j<n;j++)
printf("%d",j);
}
else
{
for(j=n;j>=1;j--)
printf("%d",j);
}
}
getch();
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how do you programme Carrier Sense Multiple Access

1965


In which header file is the null macro defined?

1341


The __________ attribute is used to announce variables based on definitions of columns in a table?

1196


Explain what standard functions are available to manipulate strings?

1071


Explain how can a program be made to print the line number where an error occurs?

1203


Explain a pre-processor and its advantages.

1125


What is merge sort in c?

1043


What are the different types of control structures?

1040


What are the basic data types associated with c?

1266


formula to convert 2500mmh2o into m3/hr

985


What is the benefit of using #define to declare a constant?

1087


What is the ANSI C Standard?

1266


How many data structures are there in c?

1110


What is the use of bitwise operator?

1121


What is the full form of getch?

1266