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

#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  


How can I remove the trailing spaces from a string?

0 Answers   Aspire,


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

0 Answers  


please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(

1 Answers  






What is an volatile variable?

15 Answers   HP,


f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c?

5 Answers   Geometric Software,


what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }

3 Answers  


What is wrong with this code?

0 Answers  


Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort

3 Answers  


6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } after calling swap ,what are yhe values x&y?

3 Answers  


Write a program to give following output..... ********* **** **** *** *** ** ** * * ** ** *** *** **** **** *********

4 Answers  


Categories