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
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 |
Define circular linked list.
What is array of structure in c?
What are near, far and huge pointers?
0 Answers Hexaware, Thomson Reuters, Virtusa,
Do you know the use of 'auto' keyword?
What is the role of && operator in a program code?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
What is the use of header files?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
why we wont use '&' sing in aceesing the string using scanf
how will you write a program on linked lists using JAVA programming???????????
Find MAXIMUM of three distinct integers using a single C statement