We were required to write a program to check whether the
given number was of the form 3^n. ( i.e. 3 to the power n).
I knew that it can be done by bit manipulation but couldn't
make out the logic.
i want a solution in C/C++ language
Answer Posted / sreejesh1987
#include<stdio.h>
#include<conio.h>
void main()
{
int count=0,n,d;
clrscr();
printf("\tDigit 3powern\n");
printf("Enter a no:");
scanf("%d",&n);
d=n;
while(d%3==0)
{
d=d/3;
count++;
}
if(d==1)
printf("\nNumber %d is of 3^%d format",n,count);
else
printf("\nNumber %d is not in 3^n format",n);
getch();
}
| Is This Answer Correct ? | 17 Yes | 6 No |
Post New Answer View All Answers
If 8 men are required to complete a work in 6 days, how many men will be required to complete the same work in ½ day?
f(X)= 2X-1 + f(X-1) if X is not equal to zeroandiff(X=0)=0, Value of f(16)+f(15)-480
low temperature at the night in a city is 1/3 more than ½ hinge as higher temperature in a day. sum of the low temp and higherst temp is 100C. then what is the low temperature
What is the value of a property, which has been insured at the rate of 1/6% of its value, if the annual premium paid on it is Rs. 83.33 (in Rs.)?
A School Has 30% Students From Maharashtra .out Of These 20% Are Bombay Students. Find The Total Percentage Of Bombay?
i need icet solved papers 2000 to 20010,and also mock papers,mock online
how to create the alarm using sql queries.In the sense i need to make the computer to produce beep sound for each 1 minute.(hint: by chr(7) we can produce the beep sound)
A clock showing 6 o'clock takes 30 secs to strike 6 times.How long will it take to strike 12 at midnight?
The ratio of the length : breadth : height of a cuboid is 5 : 4: 3, and the volume is 7500. What will be its surface area ?
There is a lucky draw held every day. If there is a winning number eg. 1876, then all possible numbers like 1867 ,1687,1768 etc are the numbers that match irrespective of the position of the digits. Thus all these numbers qualify fr the lucky draw prize. Assume there is no zero digit in any numbers. Write a program to show all the possible winning numbers if a "winningnumber" is passed as an argument to the function. i want a solution in c/c++ language
hai friends i have finished my B.E CSE in 2009.now i have to get a interview opportunity from HP software ,chennai.please any one can send me the last year(2009) interview questions with answers for freshers.i want a full details about HP's interview question with answers,procedures also.such these one year i had try to get my job but still i have not get.so plese send me that what i said....by vijay,chennai
Find the next number in the series 0,3,8,15,,24,48,63--
Jane works at a fashion design company,and is having problems getting dressed for work. She refuses to wear any color combination that does not go well together as many of her clients may look down upon this. She has two pairs of skirts, brown and blue; three blouses, white, sky blue, and gray; four pairs of stockings, red, black, brown, and blue; and two pairs of shoes, black and brown. The blue skirt cannot be worn with red or brown stockings. Gray does not go well with brown. Black does not go well with brown. 1. If Jane wears black shoes she will not wear: a) red stockings. b) a blue skirt. c) a white blouse. d) blue stockings. e) a sky blue blouse. 2. If Jane is color blind and is unable to determine what outfits went well together, how many possible clothing combinations could she have? a)24 b)32 c)36 d)44 e)48 3. If Jane wears a brown skirt and a white blouse, she could: a)not wear blue stockings. b)not wear brown shoes. c)not wear black shoes. d)wear blue stockings. e)wear red stockings. 4.Jane buys a gray scarf. If she wears the new scarf, then she could: a)not wear blue stockings. b)not wear brown stockings. c)not wear black shoes. d)wear a white blouse. e)wear black stockings. 5.Jane will never wear: a)blue and red together. b)white and red together. c)gray and blue together. d)white and black together. e)white and red together.
If p/q = 5/4 , then 2p+q= ?
If A, B and C are the mechanisms used separately to reduce the wastage of fuel by 30%, 20% and 10%. What will be the fuel economy if they were used combined.