First Upload
This commit is contained in:
32
4/ex3.c
Normal file
32
4/ex3.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user