64 757
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #54895 in C++ for Charles

Question #54895
How to make a for loop version of simulating multiplication using repeated addition? Using printf and scanf and only the header stdio.h?
Expert's answer
#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!

Comments

Charles
23.09.15, 20:38

Thanks this will help a lot

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions