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 |
Write a program which returns the first non repetitive character in the string?
write a own function for strstr
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
If errno contains a nonzero number, is there an error?
Combinations of fibanocci prime series
Here is a good puzzle: how do you write a program which produces its own source code as output?
How do we select the big element or any other operation from array which is read dynamically. user need to give the elements only no need to mention the size.
Explain what header files do I need in order to define the standard library functions I use?
program to locate string with in a string with using strstr function
why you will give me a job in TCS.
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL
What are bitwise shift operators in c programming?