Â
In this, we are going to see while loop, the program is based on while loop which prints, table of any number you want.
The code given below can be used for TURBO C++ Compiler:-
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n;
int i = 1;
cout << "Enter the no. : \n";
cin >> n;
while (i <= 10)
{
cout << n << " * " << i << " = " << n * i << endl;
i++;
}
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
int main()
{
int n;
int i = 1;
cout << "Enter the no. : \n";
cin >> n;
while (i <= 10)
{
cout << n << " * " << i << " = " << n * i << endl;
i++;
}
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP