Assignment-IV
Assignment-IV
Assignment – IV
1. A positive integer is entered through the keyboard, write a C function to find the binary
equivalent of this number using recursion.
2. Write a recursive function which returns the sum of individual digits of a number passed as
argument.
3. Write a program that reads a line and converts it into all capitals without using any string library
function. (input string may also contain capital letters)
4. Write a program to count the number of occurrences of any two vowels in succession in a line of
text.
5. Write a program that converts a string like “123” to integer 123. Do not use any string library
function.
6. Write a C program which dynamically allocates memory for two matrices, orders of which is
given by the user, and reads the values of elements of the matrices from the user. The program
creates a third matrix which is obtained by multiplying the two input matrices. Your program should
check for conformity of multiplication of the two matrices given by the user.
7. Write a C program which accepts an integer and creates a string representation of the integer
value. Do not use any string library function. [Example: If the argument is integer 1234 the program
should form the string “1234”]
8. Write a C program which accepts a string from user and checks whether it is palindrome or not.
Do not use any string library function. [Example of a palindrome string: "abcba", "abba"]
9. Write a C program which accepts a string from user and counts the number of words in it. Do not
use any string library function.
10. Write a C function which accepts a string str1 and returns a new string str2 which is str1 with
each word reversed. Do not use any string library function.
11. Write a function squeeze(s,c) which removes all occurrences of the character c from the string s.
12. Write the function strend(s,t), which returns 1 if the string t occurs at the end of the string s, and
zero otherwise.
13. Write a C function convert(int n, char *s, int w) that accepts three arguments. The function
stores the string representation of n in s. The third argument w is a minimum field width; the
converted number must be padded with blanks on the left if necessary to make it wide enough.
[OPTIONAL]
14. Write a C function which takes as argument two strings str1 and str2. It creates a third string str3
which is formed by taking alternating characters from each string and returns it. Example: If the two
string arguments are “abcd” and “efgh” the function should return the string “aebfcgdh”, If the two
string arguments are “abcd” and “efghijkl” the function should return the string “aebfcgdhijkl”. Do
not use any string library function. [OPTIONAL]
15. Write a C function which takes as argument two strings str1 and str2 and an integer i. It returns a
new string which is obtained by appending str2 from the ith character in str1. Example: If the two
string arguments are “abcd” and “pqrs” and i is 2, then the function should return the string
“abpqrs”. Do not use any string library function. [OPTIONAL]