Answer to Question #54895 in C++ for Charles
How to make a for loop version of simulating multiplication using repeated addition? Using printf and scanf and only the header stdio.h?
1
2015-09-23T10:26:17-0400
#include <stdio.h>
int main()
{
int a;
printf("Enter a:");
scanf("%d", &a);
int b;
printf("Enter b:");
scanf("%d", &b);
int result = 0;
for (size_t i = 0; i < a; i++)
{
result += b;
}
int res = 0;
for (size_t i = 0 ; i < a; i++, res+=b)
{
}
printf("Res: %d \n", res);
printf("Result: %d \n", result);
printf("Test: %d \n", a*b);
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!
Learn more about our help with Assignments:
C++
Comments
Thanks this will help a lot
Leave a comment