Answer to Question #190683 in C++ for Asma M.Hussain

Question #190683

Differentiate between different loops in form of table and write a same logic programe by using all loops, programe mentioned below:

Programe: Write a programe that input value and range from user,

Display multiplication table up to a given range by using For ,while and do-while loops.


1
Expert's answer
2021-05-08T07:25:53-0400




#include <iostream>


using namespace std;




int main(){
    int value;
    int range;
    cout<<"Enter value: ";
    cin>>value;
    cout<<"Enter range: ";
    cin>>range;


    cout<<"\n Multiplication table up to "<<range<<" using for loop"<<endl;
    //using for loop
    for(int i=1;i<=range;i++){
        cout<<value<<" * "<<i<<" = "<<value*i<<endl;
    }


    cout<<"\n Multiplication table up to "<<range<<" using while loop"<<endl;
    //using while loop
    int i=1;
    while(i<=range){
        cout<<value<<" * "<<i<<" = "<<value*i<<endl;
        i++;
    }


    cout<<"\n Multiplication table up to "<<range<<" using do while loop"<<endl;
    //using do while loop
    int j=1;
    do{
       cout<<value<<" * "<<i<<" = "<<value*j<<endl;
        j++;
    }
    while(j<=range);


    return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS