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 C++ program without using any loop (if, for, while
etc) to print numbers from 1 to 100 and 100 to 1;

Answer Posted / om

#include<stdio.h>
void print_1_to_100(int n);
void print_100_to_1(int n);

int main()
{
print_1_to_100(1);
return 0;
}

void print_1_to_100(int n)
{
printf("%d\t",n);
(n/100)? print_100_to_1(n) :print_1_to_100(n+1);
}


void print_100_to_1(int n)
{
printf("%d\t",n);
(n-1)? print_100_to_1(n-1) :1;
return;
}

//SAMPLE OUTPUT
1 2 3 4 ....100 100 99 98 ...2 1

Is This Answer Correct ?    52 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to write a multi-statement macro?

1052


What is floating point constants?

1142


What does the function toupper() do?

1138


why do some people write if(0 == x) instead of if(x == 0)?

1084


Explain what does the function toupper() do?

1083


How can I find out if there are characters available for reading?

1115


How to establish connection with oracle database software from c language?

2207


What are data types in c language?

1063


How can I handle floating-point exceptions gracefully?

1181


what are # pragma staments?

2049


What is a scope resolution operator in c?

1282


How do you redirect a standard stream?

1116


What is c definition?

1283


simple program of graphics and their output display

2005


What is sizeof return in c?

1041