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 |
How can I call a function with an argument list built up at run time?
How can I call fortran?
What are the advantages of using linked list for tree construction?
the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters
what is a headerfile?and what will be a program without it explain nan example?
Write a program to compute the following 1!+2!+...n!
What are preprocessor directives?
What does s c mean on snapchat?
write a program to copy a string without using a string?
What is external variable in c?
How many parameters should a function have?
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance