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 |
Why can't we initialise member variable of a strucutre
What does the function toupper() do?
what is calloc and malloc?
how to reverse string "Hello World" by using pointers only. Without any temp var
What is an example of structure?
How can I send mail from within a c program?
program for comparing 2 strings without strcmp()
What is c language and why we use it?
read an array and search an element
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
what is c language?
What is class and object in c?