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 |
This is on letter series like if DEFGHI: ABCDEF then NOPQRS:_______
11 Answers EA Electronic Arts, TS,
3, 5, 8, 13, 24, 39, 72 FIND THE WRONG NUMBER
Find the hypotaneous of a right angle isosceles triangle whose area is 50.
If in a certain code 'RANGE' is coded as 12345 and 'RANDOM' is coded as 123678, then the code for the word 'MANGO' would be
12 Answers Cli3l, Infosys, Wipro,
One year payment to the servant is Rs. 200 plus one shirt. The servant leaves after 9 months and receives Rs. 120 and a shirt.Then find the price of the shirt.
If Log2 x - 5 Log x + 6 = 0, then what would the value / values of x be?
I am preparing for APSRTC Officers under training,i would like to know the syllabus for this post's written test also Suggest me the reference books for Managerial Aptitude, General Knowledge, General English. Kindly send reply to my mail id pulijalasrikanth@gmail.com
Sister's age is twice than that of the brother. If the brother's age is six, what is the sister's age after two years?
0 Answers BPCL Bharat Petroleum, Sonata,
there are 76 persons. 53 can read hindu,46 can read times,39 can read deccan and 15 can read all.if 22 can read hindu and deccan and 23 can read deccan and times then what is the number of persons who read only times and hindu………
The following question asked at Infosys campus recruitment held at Pragathi. If 1>= y > x and xy=z.which of the following is not true? i)z>0 ii)x=z iii)y=z iv)z>y
if a=2, b=3, c=6 Find the value of c/(a+b)-(a+b)/c
a vendor solds two things at same cost 12 RS with one item at 25%profit and other at 20%loss,by this transaction he made profit or loss by how much