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