I need help with this program. While-loop and function: Write the body of a func
ID: 3617570 • Letter: I
Question
I need help with this program. While-loop and function:Write the body of a function that will output the multiplicationsof numbers from 1*1 to n*n in order.
- The function has an input parameter, n which is the upperbound.
- On each line, the product of two numbers should be printedalong with two numbers.
Use: Print a char * Print a char =Do NOT use: Print a char '*'Print a char '='Examples:
If n is 3, the output should be
1*1=11*2=21*3=32*1=22*2=42*3=63*1=33*2=63*3=9If n is 5, the output should be
1*1=11*2=21*3=31*4=41*5=52*1=22*2=4...5*3=155*4=205*5=25I need help with this program. While-loop and function:
Write the body of a function that will output the multiplicationsof numbers from 1*1 to n*n in order.
- The function has an input parameter, n which is the upperbound.
- On each line, the product of two numbers should be printedalong with two numbers.
Use: Print a char * Print a char =Do NOT use: Print a char '*'Print a char '='Examples:
If n is 3, the output should be
1*1=11*2=21*3=32*1=22*2=42*3=63*1=33*2=63*3=9If n is 5, the output should be
1*1=11*2=21*3=31*4=41*5=52*1=22*2=4...5*3=155*4=205*5=25
Explanation / Answer
AS PER REQUIREMENTS THE PRINTING IS DONE IN FUNCTION & USING WHILE LOOP:-#include<iostream> using namespace std; void print(int); int main() { int num; cout<<"Enter a number:"; cin>>num; print(num); system("pause"); return 0; }
void print (int n) { int r,c; r=1; while(r<=n)
{ c=1; while(c<=n) { cout<<r<<"*"<<c<<":"<<r*c<<endl; c++; #include<iostream> using namespace std; void print(int); int main() { int num; cout<<"Enter a number:"; cin>>num; print(num); system("pause"); return 0; }
void print (int n) { int r,c; r=1; while(r<=n)
{ c=1; while(c<=n) { cout<<r<<"*"<<c<<":"<<r*c<<endl; c++;