C Program Assignement
C Program Assignement
C Program Assignement
**********************************************************
Write C programs to perform the following:
6. Write a C program to input two numbers and find maximum between two numbers using conditional/ternary operator
7. Input a character and change its case. (lowercase to uppercase and vice versa).
8. Input a number and check whether it is odd or even and display accordingly.
9. Find the largest and smallest among three numbers supplied by user.
10. Check whether an input year is a leap year or not.
11. Input two numbers and swap them using bitwise operators.
12. Convert an unsigned integer to its equivalent binary using bitwise operator.
13. Find the maximum of three numbers using ternary operator.
14. Implement simple arithmetic calculator using switch case.
15. Display the number of days for a given month.
E.g – User’s choice – 1. January, Output – 31,
2. February – Output – 28
(Need not consider leap
year)
16. Input a character from the user and check if it is a vowel or a consonant.
(a) *
**
***
****
(b) *
***
*****
*******
(c) *
***
*****
*******
***
*
(d)1
123
12345
1234567
18. Input two numbers and find their hcf and lcm.
19. Input a number and find the sum of its digits using while/do-while loop.
20. Input a number and check if it is a Palindrome number or not while/do-while loop.
21. Input a number and check if it is a prime number or not.
22. Input a number and check whether it is an Armstrong number or not using while/do-while loop.
(FUNCTIONS)
23. Input a number n and find its factorial using a user defined function long int fact(int)
24. Input a number and check if it a Krishnamurthy number.
25. Find the sum of first n prime numbers using as user defined function to check for prime. Input the value of n from
the user.
26. Input a limit n and print all prime fibonacci numbers up to n using a user defined function int prime(int) which
returns a 1 if the argument is a prime or else 0.
27. Input a limit n and print all twin prime numbers up to n.
(ARRAYS)
32. Write a C program to declare, initialize, input elements in array and print array.
49. Find the sum of the elements of an array using an user defined function int sum(int*,int). The function should accept
the array and the number of elements as arguments.
50. Sort an array of n elements using an user defined function int selection(int*,int), employing selection sort technique.
The function should accept the array and the number of elements as arguments.
51. Create a dynamic 1D array to store n elements and perform binary search on them.
52. Create a dynamic 2D array to store (m x n) elements and find its upper triangular matrix.
(STRINGS)
53. Implement strlen(), strcat(), strrev(), strcpy(), strcmp(), strcmpi() without using standard library functions.
54. Enter a sentence and find number of vowels, consonants, spaces and special characters.
55. Input a string that contains digits as well as characters. Find the sum of the digits.
56. Input a string and find sum of the ASCII values of all characters.
57. Input a string and check if it a palindrome or not.
58. Input a string and count the number of words in it.
59. Input a name and find its initial (e.g., Subhash Chandra Bose should be printed as S. C. B).
60. Input a string and delete all consecutive occurrences of characters.
61. Write a C program to design a structure named XYZ with one integer and one float member. Declare 3 variables
V1, V2 and V3 of this structure. Input the values of members V1 and V2. Finally, add members of V1 and V2 and
keep the results in V3 and print it.
62. A student of honours class can have following attributes: roll (int), age (int), name (char []), sex (char), marks (int).
Write a program to input ‘n’ student records with the above attributes and find out how many of them are eligible to
vote. Also determine the 1st boy or girl (mention Mr. or Miss).
63. An angle is measured in degree and minutes. Write a program to specify a structure angle to measure an angle in
degree and minutes. Using a function angle sumangle (angle, angle), find the resultant angle after adding the two
angles and display the result with the help of the function void display (angle).
64. Accept two complex numbers and display their sum, difference and the modulus of the result after addition and
subtraction using the following specifications:
struct complex
{
float real, img;
};
complex sum (complex, complex);
complex difference (complex, complex);
void display modulus (complex);
RECURSION
(FILE HANDLING)