45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
#include <stdio.h>
|
|
#define ONE 1
|
|
#define TWO 2
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 2_7
|
|
// ------------
|
|
//
|
|
// General : The program change letters by one depends on situation.
|
|
//
|
|
// Input : 2 letters.
|
|
//
|
|
// Process : The program checks if the first letter is before the second in
|
|
// the ABC and acts accordingly.
|
|
//
|
|
// Output : '1' if is it True, '0' is false.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 19.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
char a,
|
|
b,
|
|
final_a,
|
|
final_b,
|
|
opr = '+';
|
|
|
|
printf("Enter 2 chars: ");
|
|
scanf("%c%c", &a, &b);
|
|
|
|
final_a = a + ONE;
|
|
final_b = b - ONE;
|
|
|
|
if (a > b)
|
|
{
|
|
final_a -= TWO;
|
|
final_b += TWO;
|
|
opr = '-';
|
|
}
|
|
|
|
printf("%c %c %c\n", final_a, opr, final_b);
|
|
}
|