Skip to main content

Posts

Showing posts with the label C Programming

PROBLEM SHEET 2

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod. The softcopy in .pdf is available  here . There is something much more in the file. 1) Predict the output of the following code snippets. Clearly specify the reasons for your answer. a) main() {     float a = 0.7;     printf("%d %d", sizeof(a),sizeof(0.7)); } b) main() {     float expr = 2.0;     switch (expr)     {         case 1.0: printf("One\n");         case 2.0: printf("Two\n");         default: printf("Default\n");     }    } 2) A character is entered through the keyboard, write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol. The following table shows t...

PROBLEM SHEET 3

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod. The softcopy in .pdf is available  here . There is  a bit more in the file. 1)A generalized Fibonacci sequence is a sequence of numbers such that from the third number onwards, each number is the sum of preceding two numbers. An example of generalized Fibonacci sequence is: 2, 5, 7, 12, 19, · · · · · · , but 1, 2, 3, 4, · · · · · · is not. You are to write a program that, given a sequence of numbers, decides whether the sequence is a generalized Fibonacci sequence or not. 2)There are 500 light bulbs (numbered 1 to 500) arranged in a row. Initially they are all OFF. Starting with bulb 2, all even numbered bulbs are turned ON. Next, starting with bulb 3, and visiting every third bulb, it is turned ON if it is OFF, and it is turned OFF if it is ON. This procedure is repeated for every fourth bu...

PROBLEM SHEET 4

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod. The softcopy in .pdf is available  here . There is  a bit more in the file. 1)Write a program to reverse the contents of an 1D array without using a second array. 2)Assume that an integer array contains duplicate entries. Find the mode of this array. Mode is that element that occurs the most number of times. A sample input and output is shown below: Enter array size 7 Enter 7 elements 2  1  -1  2  -1  4  -1 The mode is  -1 3)Rotate an array r times. Print the array after each rotation. A sample input and output is shown below. Enter the array size 5 Enter the elements 10 7 8 25 16 How many times you want to rotate? 3 Array after rotation 1 16 10 7 8 25 Array after rotation 2 25 16 10 7 8 Array after rotation 3 8 25 16 10 7 4)An election is contested by 5 candidates whose symbols are @, #, $, % and...

PROBLEM SHEET 4

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod. The softcopy in .pdf is available  here . There is  a bit more in the file. 1)Write a program to reverse the contents of an 1D array without using a second array. 2)Assume that an integer array contains duplicate entries. Find the mode of this array. Mode is that element that occurs the most number of times. A sample input and output is shown below: Enter array size 7 Enter 7 elements 2  1  -1  2  -1  4  -1 The mode is  -1 3)Rotate an array r times. Print the array after each rotation. A sample input and output is shown below. Enter the array size 5 Enter the elements 10 7 8 25 16 How many times you want to rotate? 3 Array after rotation 1 16 10 7 8 25 Array after rotation 2 25 16 10 7 8 Array after rotation 3 8 25 16 10 7 4)An election is contested by 5 candidates whose symbols are @, #, $, % and...

PROBLEM SHEET 5

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod. The softcopy in .pdf is available  here . There is  a bit more in the file. 1) Calculate the mean, variance and standard deviation of a set of numbers. 2) A m × n matrix M is said to have a saddle point if there is an entry M[i][j] such that it is the smallest value in row i and the largest value in column j. For example, consider the matrix: 20   30   40 56   78   45 1   2   3 Here 45 is the saddle point because it is the smallest in row1 but largest in column2. Given a matrix, find the saddle point if it exists. 3) Determine the norm of a matrix. Norm is defined as the square root of the sum of the squares of matrix elements. A sample input and output is shown below: Enter the size of matrix 2  3 Enter 6 elements 1  2  3  4  5  6 The matrix is 1...