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

Define circular linked list.

0 Answers  


What is array of structure in c?

0 Answers  


What are near, far and huge pointers?

0 Answers   Hexaware, Thomson Reuters, Virtusa,


Do you know the use of 'auto' keyword?

0 Answers  


What is the role of && operator in a program code?

0 Answers  






WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1 Answers   IBM,


What is the use of header files?

0 Answers  


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

0 Answers  


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

1 Answers   CMS,


why we wont use '&' sing in aceesing the string using scanf

0 Answers   HCL,


how will you write a program on linked lists using JAVA programming???????????

1 Answers   Keane India Ltd,


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


Categories