Module: Introduction to Programming
7. Indicative Content
Introduction to Programming and C Language Basics
History and importance of C programming language.
Structure of a C program: basic syntax, comments, variables, constants.
Data types: int, float, char, double, etc.
Operators: arithmetic, relational, logical, conditional.
Input and output functions: printf, scanf.
Control structures: if-else, switch-case, loops (for, while, do-while).
Functions and Modular Programming
Function basics: declaration, definition, parameters, return types.
Function prototypes and header files.
Arrays and Strings
Arrays: declaration, initialization, accessing elements.
Multi-dimensional arrays., etc).
Structures and Unions
Structure basics: declaration, accessing members
Arrays of structures
Pointers
Pointers: declaration, initialization, indirection operator (*), pointer arithmetic.
Passing pointers to functions.
File Handling
File operations: fopen, fclose, fread, fwrite
Practical Activities/Projects
1. Write a simple C program that prints the messa “ You are welcome in C
Programmingmnmnmmmmmmmm2"
2. Create a program that reads input and prints it
3. Write a program to declare variables of different data types (int, float, char) and
perform basic arithmetic.
4. Write a c program to perfom Arithmetic Operators, Logical Operators,
Assignment Operators, Increment and Decrement Operators, Conditional
(Ternary) Operator, Sizeof Operator and Address-of (&a).
5. Build a program that swaps two variables using a temporary variable.
6. Create a program that checks whether a given number is even or odd
7. Develop a program that prints numbers from 1 to 10 using a for loop, do loop
and While loop
8. Write a program to determine the largest of three numbers
9. Write a program by using menu for adding, calculating the remainder,
subtracting
and dividing and multiplying two integer numbers.
Note: The menu should look like this:
+ Addition
- Subtraction
* Multiplication
D or d Division
M or Modules
E or e Exit
10. Write a program for sorting a list of n numbers using a function
11.Write a c program to display how many odd numbers between two number
read from the keyboard.
i) If the first number is smaller like this:
Example : Enter number 1: 2
Enter number 2: 20
ii) If he first number is bigger like this :
Enter number 1: 20
Enter number 2: 2
12.Write a c program to sort in ascending order a list of n floating numbers
13.Write a c program to sort in descending order a list of n names
14.Write a c program to read two matrices and make addition of them
15. Write a c program for adding two matrices
16. Create a program that initializes an array and finds the largest element in it
17. Write a program that sorts an array of integers using bubble sort, Selection Sort
18. Write a c program to add 3 floating number using 3 types of functions ( i) void add(),
float add(), float add (float n1, float n2, float n3)
19. Write a c program to display the following information for 5 staff of unilak:
Employe no, Fname,Lname, sex,age, department, salary per month
Note :
1. Solve the problem 8 without using array of structure and read from the
keyboard
2. Use array of structures
3. Read information of 5 staff from the keyboard
4. Use initialization for solving the problem
20. write a c program to calculate the net salary of n employee of INILAK and
display the following information:
Frist Name, Last Name, Function,Sex,Age, Basic salary:,Bonus:,Tax:, Rama, Net
salary:
NOTE:1.Tax is calculated as 30% of the basic salary
2.Rama is calculated as 15% of the basic salary
3.Bonus is calculated based to the function of the employee if the function is "D"
which means director the bonus will be 25% of the basic salary and if the function is "o"
which means ordinary staff the bonus is calculated as 20% of the basic salary.
21. Create a program that swaps two numbers using pointers.
22. Write a program to read from and write to a file
23.Write a c program to make a registration of UNILAK student in each academic
year using a file
Note : The structure of the file is looking like
Note : The structure of the file is looking like
Reg Fname Last Name Sex Acadimic Year Age Faculty Department
100 John Mugisha M 2020 20 CIS Networking
101 Jane Kamugisha F 2021 23 CIS ISM
102 Peter Bizimana M 2022 19 CIS SE