100% found this document useful (1 vote)
7 views8 pages

C Programming Practicals1 - Buea - 24

The document outlines practical and thinking exercises for a C programming course at HIBMAT University for the 2024-2025 academic year. It includes tasks for displaying messages, performing arithmetic operations, and implementing algorithms using various programming constructs. Additionally, it contains past HND questions and exercises related to programming concepts and real-world applications.

Uploaded by

ngontioyvan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
7 views8 pages

C Programming Practicals1 - Buea - 24

The document outlines practical and thinking exercises for a C programming course at HIBMAT University for the 2024-2025 academic year. It includes tasks for displaying messages, performing arithmetic operations, and implementing algorithms using various programming constructs. Additionally, it contains past HND questions and exercises related to programming concepts and real-world applications.

Uploaded by

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

HIBMAT UNIVERSITY INSTITUTE OF BUEA (HUIB)

HIBMAT UNIVERSITY INSTITUTE OF DOUALA (HUID)

SCHOOL YEAR: 2024-2025 LEVEL: HND 1, SEMESTER: 2


INSTRUCTOR: NGOLAH KENNETH TIM (PhD. Cand. SWE, MSc. CSc & Eng) DEPARTEMENT: CCE
COURSE CODE: C Programming

PRACTICAL/TUTORIAL SHEET

A. PRACTICING EXERCISES:
Practice the following C programming codes:
1. To display "hello world"

2. To display "Welcome to HIBMAT University"

3. To get an integer number from the user and display it on the screen
4. To get an integer number from the user and check if it is positive or negative

5. To get an integer number from the user and check if it is odd or even

6. To get two integer numbers from the user and displays the sum and average

7. To get two real numbers from the user and displays the sum and average

8. To get two integer numbers from the user and check if one is bigger or both are equal
B. THINKING EXERCISES:
Write a C Program making use of strings, if statements, for loop, while loop, do while loop,
arrays, functions, pointers, files where necessary. Comment your work to make it explicit.

1. To prompt for three integer values from the keyboard and prints the highest of the numbers on the screen
using:
a) if statement
b) case statement
2. To display the sum and the average of the first 100 integer numbers on the screen using:
a) for loop
b) while loop
c) Do while loop
3. To convert from Decimal to Binary number system
4. To get an integer number and checks if it is odd or even. If odd, add 1, if even, add 2
5. To get an integer number and check if it is prime or not
6. To get an integer number and get the first and last digit then add them
7. To get an integer number and display the factors
8. To get two integer numbers and look for the LCM and HCF
9. To count number of digits in an integer
10.To check if a number is a Strong number or not. (a Strong number is a special number
whose sum of factorial of digits is equal to the original number. For example: 145 is
strong number. Since, 1! + 4! + 5! = 145)
11.To check if a number is an Armstrong number or not. (An Armstrong number is a n-digit
th 1
number that is equal to the sum of the n power of its digits. For example 6 = 6 = 6 ; 371
3 3 3
= 3 + 7 + 1 = 371)
12. To print Fibonacci series (Fibonacci series is a series of numbers where the current
number is the sum of previous two terms. For Example: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... , (n-
1th + n-2th)
13. To check whether the number is Perfect number or not (Perfect number is a positive integer
which is equal to the sum of its proper positive divisors. For example: 6 is the first perfect number
Proper divisors of 6 are 1, 2, 3 Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect number)

C. PAST HND QUESTIONS

SWE 2025 PRACTICALS


GROUP 1
EXERCISE 1
1. Provide the characteristics of a variable
2. Provide different data types used in programming
3. Give the syntax of a function
4. Using a function, write a program to find the maximum of 3 variables inputted from the keyboard
5. Give the syntax of an Array
6. Write a program using Array of 3 elements and find the average

Exercise 2
Design the algorithm of question 6 and implement it in the language of your choice using your computer.

SWE 2025 PRACTICALS


GROUP 2
EXERCISE 1
1. Draw a table to give the meaning of the following operators with examples using the language of your
choice. (20 marks) =CA
a. Arithmetic Operator c. Relational Operator
b. Logical Operator d. Equality Operator
2. Give the syntax, the flow chart and an example of the following loops 15marks
a. for loop c. do while loop
b. while loop
3. With an example, contrast the following concepts: (20 marks)
a. syntax of a function
b. function declaration
c. function definition
d. function call
Exercise 2 :Bug Collector (45 marks) =CA
A bug collector collects bugs everyday for 5 days. Design the algorithm and write a program
that keeps the running total of the number of bugs collected during the 5 days. The loop should ask
for the number of bugs collected for each day and when the loop is finished, the program should
display the number of bugs collected.
SWE 2025 PRACTICALS
GROUP 3
EXERCISE 1
7. Draw a table that has the name, the symbols and the examples for each of the following operators indicating the
language used. (20 marks) =CA
a. Increment and Decrement c. Relational Operator
b. Logical Operator d. Equality Operator
8. Give the syntax, the flow chart and an example of the following decision making statements 15marks
d. simple decision e. double decision f. multiple decision
9. With an example, contrast the following concepts: (15 marks)
e. syntax of a pointer
f. initialization of a pointer
g. Uses of a pointer
Exercise 2 : Shipping Enterprise (50 marks) =CA
After obtaining your hnd, you have decided to open a shipping enterprise that can ship goods inside
Cameroon or outside Cameroon. For shipping goods in Cameroon, the following conditions are applied:
1. If the weight of packet is less than 1000grams, you pay 500frs
2. If the weight of packet is greater than 1000g and less than 2000grams, you pay 1000frs
3. If the weight of packet is greater than 2000grams, you pay 2000frs
Out of Cameroon,
4. If the weight of packet is less than 1000grams, you pay 5000frs
5. If the weight of packet is greater than 1000g and less than 2000grams, you pay 10000frs
6. If the weight of packet is greater than 2000grams, you pay 20000frs
Work required:
1. Design an algorithm for the work
2. Implement it in the language of your choice

SWE 2025 PRACTICALS


GROUP 4
EXERCISE 1 20 marks
1) Consider the C program fragment below =CA

1. int x = 10, y = 15, z, k,w,a,b, *p;


2. y= x++;
3. x = y ++;
4. z = x++ + ++y;
5. k=7>3? x:y;
6. w=9+7%2;
7. a=x&&y%2;
8. b=3&2;
9. p=&x;
10. printf(" %d %d %d %d %d %d %d\n",x,y,z,k,w,a,b,*p);
a) Simulate the program and indicate the output of x,y,z,k,w,a,b*p
2) With an example, contrast the following concepts: (15 marks)
a. syntax of a pointer
b. initialization of a pointer
c. Uses of a pointer
3) Give the syntax of a 2 dimensional Array (5 marks)
4) Write a program that prints an identity matrix of 2 dimension (10 marks)

Exercise 2 : Shipping Enterprise (50 marks)


After obtaining your hnd, you have decided to open a shipping enterprise that can ship goods inside
Cameroon or outside Cameroon. For shipping goods in Cameroon, the following conditions are applied:
7. If the weight of packet is less than 1000grams, you pay 500frs
8. If the weight of packet is greater than 1000g and less than 2000grams, you pay 1000frs
9. If the weight of packet is greater than 2000grams, you pay 2000frs
Out of Cameroon,
10. If the weight of packet is less than 1000grams, you pay 5000frs
11. If the weight of packet is greater than 1000g and less than 2000grams, you pay 10000frs
12. If the weight of packet is greater than 2000grams, you pay 20000frs
Work required:
3. Design an algorithm for the work
4. Implement it in the language of your choice
7
8

You might also like