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 prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

Answer Posted / jane

#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;
}

Is This Answer Correct ?    7 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When is a null pointer used?

1170


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

1158


How can a number be converted to a string?

1396


What is queue in c?

1161


Are the variables argc and argv are local to main?

1363


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2597


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

3373


please give me some tips for the placement in the TCS.

2161


What is wrong with this program statement?

1088


What is the difference between a function and a method in c?

1135


swap 2 numbers without using third variable?

1177


a c code by using memory allocation for add ,multiply of sprase matrixes

2864


Is c is a low level language?

1210


How can I manipulate individual bits?

1100


Is main is a keyword in c?

1177