write a program for 7*8 = 56 ? without using * multiply
operator ? output = 56

Answers were Sorted based on User's Feedback



write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / guest

add 7 ,8 times & u 'll get the output
we can use while loop,or for loop

Is This Answer Correct ?    29 Yes 2 No

write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / banavathvishnu

int main()
{

printf("%d",7<<3);
getch();
}

Is This Answer Correct ?    30 Yes 7 No

write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / pavan_mustyala

Method1:
optimised code is to "left shift" the number 7 by 3 times.

Reason: 8 is (2 raised to power 3). So (7 * 8) is
equivalent to (((7*2)*2)*2). To multiply a number by 2,
shift it by 1 bit Left.

Method2:
Not optimised but it works. Addition in a loop.

int func()
{
int i;
int result = 0;

for(i = 0; i < 8; i++)
{
result = result + 7;
}
return result;
}

Is This Answer Correct ?    14 Yes 4 No

write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / rama krishna sidhartha

Here is the logic.
void func()
{
int i;
int result = 0;
for(i = 0; i < 8; i++)
{
result = result + 7;
}
printf("%d",result);
}

Is This Answer Correct ?    8 Yes 3 No

write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / manish soni bca 3rd year jaipu

#include<stdio.h>
#include<conio.h>
void main()
{
int i,ans;
ans=0;
for(i=0;i<8;i++)
ans=ans+7;
printf("%d",ans);
getch();
}

Is This Answer Correct ?    5 Yes 1 No

write a program for 7*8 = 56 ? without using * multiply operator ? output = 56..

Answer / raju kalyadapu

int main()
{
int i=0,n=0;
while(i++<8)
n=n+7;
printf("7 * 8 is:%d",n);
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Differentiate between the expression “++a” and “a++”?

0 Answers  


Suggesting that there can be 62 seconds in a minute?

0 Answers  


What is a memory leak in structures? How can we rectify that?

2 Answers  


what is difference between ++(*p) and (*p)++

17 Answers   Accenture, HCL, IBM,


i want to job in your company, so how it will be possible.

3 Answers   TCS,


Dont ansi function prototypes render lint obsolete?

0 Answers  


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

0 Answers  


consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value

4 Answers   TCS,


what will be the output of this program? #include<stdio.h> #define cube(x) x*x*x void main() { int i,j=5; i=cube(j+3); printf("i=%d",i); }

6 Answers   IBM,


What are unions in c?

0 Answers  


What is masking?

0 Answers  


what is different between auto and local static? why should we use local static?

0 Answers  


Categories