First Upload

This commit is contained in:
2022-02-25 15:33:16 +02:00
commit 0c74d10f0d
295 changed files with 74784 additions and 0 deletions

49
1/ex2.c Normal file
View File

@@ -0,0 +1,49 @@
#include <stdio.h>
#define TEN 10
#define ZERO 0
//---------------------------------------------------------------------------------------
// Exercise 2
// ----------
//
// General : The program change order digits - reverse order.
//
// Input : Number with 3 digits.
//
// Process : The program take the digits from right to left and multiplier the digit
// by 10.
//
// Output : Same number like input just reverse order.
//
//---------------------------------------------------------------------------------------
// Programmer : Cohen Idan
// Student No : None
// Date : 09.09.2019
//---------------------------------------------------------------------------------------
void main(void)
{
short num,
temp,
result = ZERO;
printf("Enter number with 3 digits: ");
scanf("%hd", &num);
// Take the first digit from right to left and add to result
temp = num / TEN;
result += num - (temp * TEN);
num = temp;
temp = num / TEN;
// Multiplie the result by 10
result *= TEN;
result += num - (temp * TEN);
num = temp;
temp = num / TEN;
result *= TEN;
result += num - (temp * TEN);
printf("%hd\n", result);
}