#include #define DIGITS 3 #define TEN 10 #define ZERO 0 //--------------------------------------------------------------------------------------- // Exercise 1 // ---------- // // General : The program recognize if all digits are same. // // Input : Number with 3 digits. // // Process : The program summarizes all the digits and divie by last digit. // // Output : '0' if is it True, else is false. // //--------------------------------------------------------------------------------------- // Programmer : Cohen Idan // Student No : None // Date : 09.09.2019 //--------------------------------------------------------------------------------------- void main(void) { short num, temp, sum = ZERO; printf("Enter number with 3 digits: "); scanf("%hd", &num); // Take the first digit from right and add to sum temp = num / TEN; sum += num - (temp * TEN); num = temp; temp = num / TEN; sum += num - (temp * TEN); num = temp; sum += num; // Divie the sum by last digit from right and check if (Rest == 0) and // (result == (count of digits)) temp = sum / num; sum %= num; sum = sum + DIGITS - temp; printf("If you got '0' then it is True, else is False: %hd\n", sum); }