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

What does s c mean on snapchat?

1055


Why is C language being considered a middle level language?

1072


What is static memory allocation?

1121


What is the purpose of void in c?

1006


How can you return multiple values from a function?

1073


How can a process change an environment variable in its caller?

1153


Why is c called a structured programming language?

1233


What is the difference between malloc() and calloc()?

1731


What happens if header file is included twice?

1103


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1813


What is the difference between variable declaration and variable definition in c?

1032


How do you print only part of a string?

980


When should the register modifier be used? Does it really help?

932


What is an lvalue?

1026


What are the __date__ and __time__ preprocessor commands?

1062