Computer Science, asked by purveshKolhe, 1 month ago

in C++ to to print numbers up to 100​

Answers

Answered by anindyaadhikari13
4

Answer:

This is the the required C++ program for the question.

1. Using loop.

#include <iostream>

using namespace std;

int main() {

   for(int i=1;i<=100;i++)  {

     cout << i << " ";

   }

   return 0;

}

2. Without using loop (recursion).

#include <iostream>

using namespace std;

int x(int n)  {

 if(n<=100){

   cout << n << " ";

   x(n+1);

 }

 return 0;

}

int main() {

   x(1);

   return 0;

}

Refer to the attachment for output.

•••♪

Attachments:
Answered by FlowerBlush
3

This program displays the prime number between 1 and 100. To understand this program you should have the knowledge of user-defined functions, for loop, C++ if-else control statement.

Attachments:
Similar questions