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 |
int i=0,j; j=++i + ++i ++i; printf(" %d",j);
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is the function of this pointer?
0 Answers Agilent, ZS Associates,
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
how to swap two integers 1 and 32767 without using third variable
which is conditional construct a) if statement b) switch statement c) while/for d) goto
write a program to concatenation the string using switch case?
c program to print a name without using semicolon
implement general tree using link list
What is array of pointers to string?
Function to find the given number is a power of 2 or not?
Explain how can you be sure that a program follows the ansi c standard?