Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



We were required to write a program to check whether the given number was of the form 3^n. ( i.e. 3..

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

Post New Answer

More General Aptitude Interview Questions

45% of 1500 + 35% of 1700 = ?% of 3175 (a) 40 (b) 55 (c) 45 (d) 35 (e) None of these

3 Answers  


Three friends divided some bullets equally. After all of them shot 4 bullets the total number of bullets remaining is equal to the bullets each had after division. Find the original number divided?

4 Answers  


Please send me the Karur Vysya Bank Clerk exam previous model papers to shekar96@gmail.com

14 Answers   Karur Vysya Bank KVB, KVB, L&T, Sugen, TCS,


14.60 x ? + 13.5 = 50

1 Answers  


series: ??,55,66,48,61,74,60,75,90

3 Answers   Satyam,


A company installed 36 machines at the beginning of the year. In March they installed 9 additional machines and then disconnected 18 in August. How many were still installed at the end of the year.

8 Answers   TCS,


2 people are playing chess daily..31 days of month..loser gives 2rs to winner per mathes..whole amt will pay at the end of month..one man gives 38rs to other & he had win 5 mathes..then how many mathes are tie??? option a)2 b)8 c)4

9 Answers   Mobisoft Infotech, Zycus Infotech,


Which number does not belong to this series 1,1,2,3,4,5,8,13,21?

0 Answers   Google,


Selling a ac gains 25% on SP.what %gain on CP. 15 25 33.33 47.5

4 Answers   Accenture,


sir i want the book for managerial aptitude for apsrtc jobs.if u know send to my mail arun9risingsun@yahoo.com

2 Answers   APSRTC,


In a certain company, 20% of the men and 40% of the women attended the annual company picnic. If 35% of all the employees are man, what percent of all the employees went to the picnic?

7 Answers   Cap Gemini, TCS,


a man has some hens and cows. If the number of heads be 48 and the number of feet equals 140, then the number of hens will be?

0 Answers  


Categories