0% found this document useful (0 votes)
15 views5 pages

C Homework

The document discusses C programs for XOR operations, right and left bit shifts, division with error handling, calculating area with a macro, finding minimum with a macro, and an enumerated data type for days of the week.

Uploaded by

asdqw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

C Homework

The document discusses C programs for XOR operations, right and left bit shifts, division with error handling, calculating area with a macro, finding minimum with a macro, and an enumerated data type for days of the week.

Uploaded by

asdqw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. The outcome of a XOR operation is true if and only if one operand (but not both) is true.

Write a
program in 'C' which returns the outcome of an Exclusive OR operation performed on its two
operands.

Solution:

2. Write a program in C to show that Right shift effectively divides a number by 2 and a left shift
effectively multiplies a number by 2.

Solution:
3. Using if else statement write a program in 'C' to read two integers from the user and display the
quotient. Your program should be able to detect divide by zero.

Solution:
4. Use the concept of macro with parameter (define a macro for area of rectangle) and call that
macro in main program to calculate area of rectangle for given length and width.

Solution:
5. Define a Function-like Macro using? operator and call that to calculate minimum of two given
numbers.
6. Write a program that creates enumerated data type for 7 days of week and shows values of
those days in integer constants.

Solution:

You might also like