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 the advantages and disadvantages of macros.
Write a program to print a (*)pattern programming (A to Z) in capital in one programming ?
What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char Space = ' '; char LineOfText; float count; LineOfText = getchar(); while ((LineOfText = getchar()) != '/n'); { count = strlen(LineOfText) - 1; while (count >= 0) { putchar(LineOfText[count]); count--; } } getchar(); return 0; }
How are variables declared in c?
what will be the output of" printf("%d%d",scanf("%d% d",&a&b));"
write a program of bubble sort using pointer?
What are the header files used in c language?
What is the function of this pointer?
0 Answers Agilent, ZS Associates,
What are header files and what are its uses in C programming?
What is the real difference between arrays and pointers?
27 Answers Hexaware, Logic Pro, TCS,
What is identifiers in c with examples?
How main function is called in c?