Q:

Write a C program to multiply two numbers using plus operator

0

C program to multiply two numbers using plus operator

This program will read two integer numbers and find the multiplication of them using arithmetic plus (+) operator. We will not use multiplication operator here to multiply the numbers.

Example:

    Input:
    Enter first number: 10
    Enter second number: 4

    Output:
    Multiplication of 10 and 4 is: 40

    Logic:
    Multiplying first number (10), second number (4) times
    Multiplication is = 10 + 10 + 10 + 10 = 40

To find multiplication of two number - Here, we are using a loop that will run second number times and adding the first number.

 

For example: if we want to multiply 10 and 4 then either we can add 10, 4 times or we can add 4, 10 times.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Multiplication of two numbers using plus (+) operator

/*C program to multiply two numbers using plus operator.*/
 
#include <stdio.h>
 
int main()
{
    int a,b;
    int mul,loop;
     
    printf("Enter first number: ");
    scanf("%d",&a);
    printf("Enter second number: ");
    scanf("%d",&b);
     
    mul=0;

    for(loop=1;loop<=b;loop++){
        mul += a;
    }

    printf("Multiplication of %d and %d is: %d\n",a,b,mul);

    return 0;
}

Output

    Enter first number: 10
    Enter second number: 4
    Multiplication of 10 and 4 is: 40

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
Write a C program to demonstrate example of global... >>
<< Write a C program to find HCF (Highest Common Fact...