0
evry1 can i get some help on how to print 4*1=4;4*2=8....in my second code....i know what to loop but dnt knw where to write it
the loop initiates from 1 and is less than upto+1;and increments by 1...help me where to put it......or suggest anything else I want to print it
1 Antwort
+ 1
Hello Syed Naqvi, I don't know how your second code looks like but from what I see, you would like to get a output of 4*1, 4*2 etc. from something like this:
#include <iostream>
using namespace std;
int main()
{
int base_number = 4; //the number used for multiplication
int resulted_number = 0; //stores the result for printing
int max_iteration = 100; //maximum number of iterations
for(int i = 1; i <= max_iteration; i++){
resulted_number = base_number * i;
cout << "Result of " << base_number << "*"
<< i << "=" << resulted_number << endl;
}
return 0;
}
I would suggest you use this in a separate function which will print your values when called, something like:
int multiplyNumber(int base_number, int max_iteration); In this manner, you will only need to provide the necessary data and the function will take care of the rest. I hope this helps you. Have a nice day. Ovidiu-Gabriel