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



Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100..

Answer / sweetsmiracle17

plz provide answer

Is This Answer Correct ?    4 Yes 2 No

Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100..

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

Post New Answer

More C Interview Questions

How can I call a function with an argument list built up at run time?

0 Answers  


How can I call fortran?

0 Answers  


What are the advantages of using linked list for tree construction?

0 Answers  


the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters

2 Answers  


what is a headerfile?and what will be a program without it explain nan example?

6 Answers   Assurgent,


Write a program to compute the following 1!+2!+...n!

4 Answers  


What are preprocessor directives?

1 Answers  


What does s c mean on snapchat?

0 Answers  


write a program to copy a string without using a string?

2 Answers  


What is external variable in c?

0 Answers  


How many parameters should a function have?

0 Answers  


can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance

1 Answers   IBM,


Categories