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 |
program that accepts amount in figures and print that in words
2 Answers Infosys, Lovely Professional University, Wipro,
pointer_variable=(typecasting datatype*)malloc(sizeof(datatype)); This is the syntax for malloc?Please explain this,how it work with an example?
2 Answers eClerx, Excel, kenexa,
What is scope and lifetime of a variable in c?
Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
What is 2 d array in c?
Why c is called object oriented language?
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?
const char * char * const What is the differnce between the above tow?.
WHAT IS LOW LEVEL LANGUAGE?
what is the structure pointer?
if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?
4 Answers Amazon, Apple, Bata, Google, NASA,