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 / 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 |
Which of the following appointments is not made by the President of India? a) Speaker of the LOk Sabha. b) Chief of Air Staff c) Chief of Army
In 29 words or fewer, describe what you would strive to accomplish if you worked at Google Labs.
3 Answers Google, Patni, Wipro,
A is twice efficient than B. A and B can both work together to complete a work in 7 days. Then find in how many days A alone can complete the work?
Bird is flying 120km/hr b/w b to r. Two trains at b to r at 60 kmph the distance traveled by the bird before it is killed.
There are 3 persons X, Y and Z. On some day, X lent tractors to Y and Z as many as they had. After a month Y gave as many tractors to X and Z as many as they have. After a month Z did the same thing. At the end of this transaction each one of them had 24. Find the tractors each originally had?
One clock ringes 7 O'clock in 7 sec.In how many seconds it will ring 10 O'clock.
If you take a marker & start from a corner on a cube, what is the maximum number of edges you can trace across if you never trace across the same edge twice, never remove the marker from the cube, & never trace anywhere on the cube, except for the corners & edges?
A certain street has 1000 buildings. A sign-maker is contracted to number the houses from 1 to 1000. How many zeroes will he need?
Asish was given Rs. 158 in denominations of Rs 1 each. He distributes these in diff bags, such that ne sum of money of denomination betn 1 and 158 can be given in bags. The min no. of such bags reqd :
three friends a,b,c run around a circular track of length 120m at a speed of 5,7,15m/sec respectively starting simultaneously from the same point in the same direction .how often they three will meet????
distance D=rt where r & t are +ve and r is constant,as t increses then D_________
In base 10 representation for a rupee 100 paise,then base 8 representation what is rupee value?