32 lines
929 B
C
32 lines
929 B
C
#include <stdio.h>
|
|
|
|
#define THREE 3
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 3
|
|
// ----------
|
|
//
|
|
// General : The program prints the smallest power of 3 larger than the input.
|
|
//
|
|
// Input : Number.
|
|
//
|
|
// Process : The program check all power of 3 until that is smaller than input.
|
|
//
|
|
// Output : Number.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 23.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
unsigned short num;
|
|
unsigned int result;
|
|
|
|
printf("Enter number: ");
|
|
scanf("%hd", &num);
|
|
for (result = THREE; num > result; result *= THREE);
|
|
|
|
printf("%d\n", result);
|
|
|
|
} |