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

i have used functions.... i got this logic.

#include<stdio.h>
#include<conio.h>
void logic1(int);
void logic2();
void logic3();
void logic4();
int a=0;
void main()
{
int m;
printf("enter the number of lines :");
scanf("%d",&m);
for(int i=1;i<=(m/2+1);i++)
{
printf("\n");
if(i%2!=0)
logic1(i);
else
logic2();
}
for(i=1;i<=m/2;i++)
{
printf("\n");
if(i%2==0)
logic3();
else
logic4();
}
getch();
}
void logic1(int p)
{
a=(m/2+2)-p;
for(int i=a;i>=1;i--)
printf("%d",i);
}
void logic2();
{
a--;
for(int i=1;i<=a;i++)
printf("%d",i);
}
void logic3()
{
a++;
for(int i=a;i>=1;i++)
printf("%d",i);
}
void logic4()
{
a++;
for(int i=1;i<=a;i++)
printf("%d",i);
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a c program to build a heap method using Pointer to function and pointer to structure ?

4622


Difference between pass by reference and pass by value?

1097


What is a function in c?

1483


Are the expressions * ptr ++ and ++ * ptr same?

1087


What does malloc () calloc () realloc () free () do?

1002


How can I copy just a portion of a string?

1271


What is the purpose of void pointer?

986


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

1334


What is "Hungarian Notation"?

1033


provide an example of the Group by clause, when would you use this clause

2127


What are the features of c language?

1022


Why do we use main function?

1112


What are the c keywords?

1146


What is wrong with this program statement? void = 10;

1203


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3183