Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
30. Write a program which has 3 functions named ADD, SUB and MUL which will do addition, subtraction
and multiplication respectively. Use command line to call the functions.
31. write a program that copies the contents of one file into another. The names of the existing file and the
new file have to be accepted as command line arguments
32. write a program to display number of occurrences of a given character in a file
33. write a program to remove all blank lines from a file
34. write a program to display statistics of a file (No: of characters, No: of words, No: of lines)
35. Consider a text file. Copy its contents to an output file such that each line in the output file contain only
50 characters.
36. Design the 'find and replace' functionality of any standard editor. Write functions to perform the
functionality in a header file and a program to demonstrate in a C program
37. Write a function to write directly on screen without using printf()
38. write a function to print the ascii equivalent of all characters in a string
39. write a function atof() that converts a string s to double d
40. There are 100 records present in a file with the following structure:
struct product
{
char itemcode[6];
char itemname[20];
int qty;
};
write a program to read these records and arrange them in ascending order of itemcode and write them into a
target file.
41. Write a program that will reverse each line in a file and store it in another file
42. Write a program to find out difference in days between any two dates.
43. Write a program to display binary equivalent of a given decimal number
44. Write a program to display decimal equivalent of a given binary number
45. Write a program to display hex equivalent of a given binary number
46. Write a program to display decimal equivalent of a given hex number
47. Write a program to display binary equivalent of a given hex number
48. Write a program to sort a list of strings
49. write a program to multiply two matrices
50. Write a program in which define 'a' as an unsigned integer whose value is 0xa2c3 (hexadecimal). Write
the corresponding bit pattern for this value. Then evaluate each of the following bitwise expressions, first
showing the resulting bit pattern and then the equivalent hexadecimal value. Utilise the original value of
'a' in each expression. Assume that 'a' is stored in a 16 bit word.
a) ~a
b) a ^ 0x3f06
c) a | 0x3f06
d) a >> 3
e) a << 5
f) a ^ ~a
g) a ^~a
h) a | ~a
i) (a & ~0x3f06) << 8)
j) a & ~(0x3f06 >> 8)
51. Write a program to encrypt a string and decrypt it using your own method of encryption and decryption.
52. Write a program to remove all the comments from a 'C' program.
53. Use bit manipulation to write following program :
create a structure which is having 3 variables var1, var2 and var3. var1 is of 2 bits, var2 is of 2 bits and
var3 is of 3 bits. Do add and multiplication over var1 and var2 and store result in var3 and print that
value. What is the problem are you getting in the result? How this problem can be resolved? Take input as
a command line argument.
54. Write a program to know which endianess does your system support
55. Write a C program that will illustrate the equivalence between
a) Shifting a binary number to the left n bits and multiplying the binary number by 2n
b) Shifting a binary number to the right n bits and dividing the binary number by 2n.
Choose the initial binary number carefully, so that bits will not be lost as a result of the shifting operation.
56. Write a program to reverse the byte order of given value. Reversing of byte order means to change the
endianess of data.
57. Write a endianess independent code in C.
58. Write a C program which is having ADD, SUB, and MUL as three functions. Implement conditional
compilation to access at a time one function among the three.
59. For the question number 22, compile a static library that will include all the calculator function's .o files
and then compile and execute the calculator.
60. Write a program of 'Match stick game' between the computer and a user. Your program should ensure that
the computer always wins.
Rules for the game are as follows:
- there are 21 match sticks
- the computer asks the player to pick 1,2,3 or 4 match sticks
- after the person picks, the computer does its picking
- whoever is forced to pick up the last matchstick losses the game.