Question: Programming Exercise Objective: In this lab assessment, you will demonstrate what you have learned with respect to o main() and other user defined functions o
Programming Exercise Objective: In this lab assessment, you will demonstrate what you have learned with respect to o main() and other user defined functions o Macros o Pre-processor directives, Variables and libraries usage o C compiler practice o How to run C code effectively o Input validation and proper error message
Program #1: Write a small program: {(00_Numbers.c)} that:-
1. Prints the numbers from 1 to 100
2. If the number is a multiple of three, it should print instead I'm a multiple of 3!
3. If the number is a multiple of five, it should print instead I'm a multiple of 5!
4. If the number is a multiple of three and five, it should print instead I'm a multiple of 3 && 5!
This program should not take you more than 10 minutes to write. The following demonstrates the execution of the program:
#./00_Numbers
...
Abc [input validation required]
8 [A proper error message]
9 I'm multiple of 3!!!
10 I'm multiple of 5!!!
11 [A proper error message]
12 I'm multiple of 3!!!
13 [A proper error message]
14 [A proper error message]
15 I'm multiple of 3 && 5!!!
# echo $? [Macro utilization]
0 [returns zero]
SAMPLE TEST OUTPUT: 00_Numbers
Program #2:
Write a small C program: digits.c that:
5. Read an integer number from the command line using scanf( )
6. Find the number of digits in the number.
7. Prints the number of digits to the screen.
8. Finish with a value of 0.
The following demonstrates the execution of the program:
root@bahris:01_Lab# ./digits
Enter an integer: 8765
Number of digits in 8765 is 4
root@bahris:01_Lab# ./digits
Enter an integer: -98765
Number of digits in -98765 is 5
root@bahris:01_Lab# ./digits
Enter an integer: 123456789
Number of digits in 123456789 is 9
# echo $? [Macro utilization]
0 [returns zero]
SAMPLE TEST OUTPUT: digits
Program #3:
Write a small C program: reverse.c that:
9. Read an integer number from the command line using scanf( ).
10. Prints the number with its digits reversed to the screen.
11. Finish with a value of 0.
root@bahris:01_Lab# ./reverse
Enter an integer: 7654
The reversed number is 4567
root@bahris:01_Lab# ./reverse
Enter an integer: 78
The reversed number is 87
root@bahris:01_Lab# ./reverse
Enter an integer: 9870
The reversed number is 0789
# echo $? [Macro utilization]
0 [returns zero]
SAMPLE TEST OUTPUT:
Program #4: Write a small C program: bin2dec.c that:
12. Read a binary number (just 0 and 1) from the command line using scanf( ).
13. Prints the decimal number equivalent to the binary number entered.
14. Finish with a value of 0.
root@bahris:01_Lab# ./bin2dec
Enter a binary number: 1100
The decimal equivalent of 1100 is 12
root@bahris:01_Lab# ./bin2dec
Enter a binary number: 11101
The decimal equivalent of 11101 is 29
root@bahris:01_Lab# ./bin2dec
Enter a binary number: 10
The decimal equivalent of 10 is 2
SAMPLE TEST OUTPUT: bin2dec
Requirements:
2) You must implement all possible user input data verification.
3) Each function must have header comments that explain what it does, and describe/explain its inputs (if any) and return value (if any) and the code must be properly commented. Marking:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
