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!!!)

Answers were Sorted based on User's Feedback



Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100..

Answer / sweetsmiracle17

plz provide answer

Is This Answer Correct ?    4 Yes 2 No

Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100..

Answer / 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

More C Interview Questions

Explain what is a pragma?

0 Answers  


What is the difference between int and float?

3 Answers  


write a program that will print %d in the output screen??

9 Answers   Infosys,


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


Explain low-order bytes.

0 Answers  


# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }

5 Answers  


What is wrong with this statement? Myname = 'robin';

0 Answers  


Explain what is gets() function?

0 Answers  


What is indirection?

0 Answers  


in malloc and calloc which one is fast and why?

1 Answers  


write a program to remove occurrences the word from entered text?

1 Answers  


int x=5; printf("%d%d%d",x,x<<2,x>>2);

2 Answers   TANCET,


Categories