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 |
Explain what is a pragma?
What is the difference between int and float?
write a program that will print %d in the output screen??
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
Explain low-order bytes.
# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }
What is wrong with this statement? Myname = 'robin';
Explain what is gets() function?
What is indirection?
in malloc and calloc which one is fast and why?
write a program to remove occurrences the word from entered text?
int x=5; printf("%d%d%d",x,x<<2,x>>2);