write a program for 7*8 = 56 ? without using * multiply
operator ? output = 56
Answers were Sorted based on User's Feedback
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 |
Answer / banavathvishnu
int main()
{
printf("%d",7<<3);
getch();
}
Is This Answer Correct ? | 30 Yes | 7 No |
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 |
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 |
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 |
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 |
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
How can I remove the trailing spaces from a string?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
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?
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 :(
What is an volatile variable?
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?
what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }
What is wrong with this code?
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
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?
Write a program to give following output..... ********* **** **** *** *** ** ** * * ** ** *** *** **** **** *********