Rajshahi University of Engineering & Technology Department of Mechatronics Engineering
Rajshahi University of Engineering & Technology Department of Mechatronics Engineering
Exercises: Write algorithm, draw flowchart and C code for the following problems
1. Write a program in C to swap two numbers using function. Use call by value.
Input:
10 20
Output:
20 10
2. Write a program in C to swap two numbers using function. Use call by reference.
3. Write a program in C to convert decimal number to binary number using the function.
Input:
65
Output:
1000001
4. Write a program in C to check whether two given strings are an anagram
Input:
spare pears
Output:
yes
5. Write a C program to multiply two matrix-using pointers.
Input:
10 20 30
40 50 60
70 80 90
123
456
789
Output:
300 360 420
660 810 960
1020 1260 1500
6. Write a C program to input elements in an array and sort array using pointers
Input:
10 -1 0 4 2 100 15 20 24 -5
Output:
-5, -1, 0, 2, 4, 10, 15, 20, 24, 100,
100, 24, 20, 15, 10, 4, 2, 0, -1, -5,
7. Write a function in C to find GCD (Greatest Common Divisor) of two numbers.
Input:
10 15
Output:
5
8. Write a C program to find LCM of two numbers using recursion.
Input:
12 30
Output:
60
9. Write a function to calculate standard deviation of population.
Input:
10
1 2 3 4 5 6 7 8 9 10
Output:
2.872281