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 |
what is pointer ? what is the use of pointer?
what is the mean of c languages.
why we are using semicolon at the end of printh statment
what are the stages of compilation
Can we assign integer value to char in c?
write a code for large nos multilication (upto 200 digits)
Write a C program to multiply tho numbers without using arithmetic operator (+, -, *, /).
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
What is wrong in this statement? scanf(“%d”,whatnumber);
What is 2c dna?
How to swap 3 numbers without using 4th variable?
In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?