Home » C solved programs » C basic programs

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.

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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.