×

C Programs

C Basic & Conditional Programs

C Looping Programs

C String Programs

C Miscellaneous Programs

C program to multiply two numbers using plus operator

Problem statement

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

Multiplication of two numbers

To find multiplication of two numbers - 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.

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

C Basic Programs »

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.