Solution:-
#include <iostream>
#include <conio>
int main()
{
int x, y;
cin >> x >> y; // Let x=A, y=B
int p = 0;// Invariant: A*B = p + x*y
while (y > 0)
{
p = p + x;
y = y – 1;
}
cout << p << endl;
}
getche();
#include <iostream>
#include <conio>
int main()
{
int x, y;
cin >> x >> y; // Let x=A, y=B
int p = 0;// Invariant: A*B = p + x*y
while (y > 0)
{
p = p + x;
y = y – 1;
}
cout << p << endl;
}
getche();
0 Questions:
Post a Comment