Data Structures and Algorithms (CS506)
Lab Assignment 1
- Write a C program to find the average and standard deviation of given any n numbers. The program first ask the user the number n, and then takes n numbers. The program then computes and prints the average and standard deviation of the n numbers.
Sol. Download the Solution1 file. Open terminal and execute it by running “./solution1.o
” command.
- Write a C function to count and print the number of 1-bits in its integer argument. Again your program should ask the user to enter an integer number.Your program should run correctly regardless of the machine.Hint: The given integer can be a negative number as well. The C programming language uses 2’s complement to represent an integer.
Sol. Download the Solution2 file. Open terminal and execute it by running “./solution2.o
” command.
- In a Fibonacci sequence the sum of two successive terms gives the next term and the first three terms of the Fibonacci sequence are 0, 1, 1. Write a C function to display the first n numbers of a Fibonacci sequence. Here, n is a positive integer entered through keyboard.
Sol. Download the Solution3 file. Open terminal and execute it by running “./solution3.o
” command.
- Write a C-program to compute and print the range of the following data types.By range we mean the minimum and the maximum values that can be stored in the variable of the corresponding data type.
- char
- unsigned char
- int
- unsigned int
- short
- unsigned short
Sol. Download the Solution4 file. Open terminal and execute it by running “./solution4.o
” command.