C Program for Multiplication without Using Multiply Operator *

↑ Vote This Article

Here is another program from the series tricky code. Here I am going to show you how we can do Multiplication without using Multiply Operator *. Programs like this you will rarely get anywhere else.

Comment below to express your feeling  and suggest me new idea for more tricky code.

Logic of the code:

First you give a try to think the logic.

Here is the answer,

Let a and b are two variables then c=axb. We take 9 as a and 8 as b then c=72.

In other word we are adding 9, 8 times or adding 9, 8 times,  so simple logic. This is what I converted into programing.

Code:

//C Program for Multiplication without Using Multiply Operator *
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,s=0;
clrscr();
printf(“\nEnter the values”);
scanf(“%d%d”,&n,&m);
while(m!=0)
{
s=s+n;
m–;
}
printf(“Result = %d”,s);
getch();

}

Also read

C Program to Print HELLO without HELLO

Hope you liked my posts, give comments if you have any doubts… :)

———————————————————————————————————————————————————————————–

Tags: ,

Leave a comment