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 |
the number of shells in a judys collection is 80% of the numbers justins collection if justin has 80 more shells than judy how many shells do they have together
Alice and Bob play the following coins-on-a-stack game. 20 coins are stacked one above the other. One of them is a special (gold) coin and the rest are ordinary coins. The goal is to bring the gold coin to the top by repeatedly moving the topmost coin to another position in the stack. Alice starts and the players take turns. A turn consists of moving the coin on the top to a position i below the top coin (0 = i = 20). We will call this an i-move (thus a 0- move implies doing nothing). The proviso is that an i-move cannot be repeated; for example once a player makes a 2- move, on subsequent turns neither player can make a 2-move. If the gold coin happens to be on top when it's a player's turn then the player wins the game. Initially, the gold coinis the third coin from the top
Fill the empty slots. Three FOOTBALL teams are there. Given below the list of maches. played won lost draw Goals for Goals against A 2 2 *0 *0 *7 1 B 2 *0 *1 1 2 4 C 2 *0 *1 *1 3 7 the slots with stars are answers.
Which of the following fractions is less than 1/3 (1) 22/62 (2) 15/46
Plz send me the solved sample question papers of state bank of india
"what category of job are you looking for and why"asked from an mep engineer.
0 Answers Grocon Construction Australia,
what will u do if your sister is standing naked before u.
A person gives a secret to two other persons in 5 minutes. How long will he take to tell the secret to 768 people?
At six o'clock the wall clock struck 6 times . Checking with my watch , I noticed that the time between the first & last strokes was 30 seconds . How long will the clock take to stike 12 at mid night
In a survey, 20% of a town has a car, and 10% have a bike. 1/3rd of the car owners also own a bike. What proportion of the town does not own either a car or a bike?
A family I know has several children. Each boy in this family has as many sisters as brothers but each girl has twice as many brothers as sisters. How many brothers and sisters are there?
it has 20 mixutre conatins mil and water in the ratio 3:5,replace 4 litres of mixture with 4 litres of water what is the final ratio of milk and water.