Ceng198

Introduction to Computer Programming

Lab#2

Part 1. Error Correction



Compile and run the following program. Correct the errors if there is any.





Part 2.



a.) Equality and Relational Operators

Compile and run the following program. Analyze its output. Run the program using several numbers as inputs.





b.) Modification

Modify the program above so that

Part 3. Do It Yourself.

Write a complete C program to do following tasks:

Part 4. Do It Yourself.

In the previous example, there is a danger that the obtained second number after addition operation could be gretater than the first one. So, the modulus operator will produce a wrong result. To avoid from this danger modify the previous program as;

Part 5. Do It Yourself.

Write a complete C program to produce (exactly) the following output. This output is just a sample output and subject to change depending to your entered X and Y values. The relational operators are ==, !=, >, <, >=, <=.

Program Output:



Enter two integers, and I will tell you the relationship thery satisfy: X Y

X is not equal to Y

X is less than or equal to Y

X is less than Y