Ode Antra: C - Language Assignment Sheet
Ode Antra: C - Language Assignment Sheet
1
Code Mantra C - Language Assignment Sheet
9. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the
youngest of the three.
10. Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered
through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
11. Find the absolute value of a number entered through the keyboard.
12. Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is
greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater
than its perimeter.
13. Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one
straight line.
14. Given the coordinates (x, y) of a center of a circle and it’s radius, write a program which will determine
whether a point lies inside the circle, on the circle or outside the circle.(Hint: Use sqrt( ) and pow( ) functions)
15. Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or at the origin, viz. (0, 0).
16. Any 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 the range of ASCII values for various characters.
Characters ASCII Values
A–Z 65 – 90
a–z 97 – 122
0 – 9 48 – 57
special symbols 0 - 47, 58 - 64, 91 - 96, 123 - 127
17. If the three sides of a triangle are entered through the keyboard, write a program to check whether the
triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three
sides.
18. Using conditional operators determine:
(1) Whether the character entered through the keyboard is a lower case alphabet or not.
(2) Whether a character entered through the keyboard is a special symbol or not.
Loop Program List
1. Write a Program to print Hello 10 times using Loop.
2. Write a program to Print 1 to 10 Using Loop.
3. Write a Program to print the Table of a number which is input through the Keyboard.
For Ex:- table of 2 is {2 4 6 8 10 --------------20}
4. Write a Program to print the table of a given No input through the Keyboard but with alternate No.
For Ex:- table of 2 is {2 6 10 14 16 20}
5. Two numbers are entered through the keyboard. Write a program to find the value of one number raised to
the power of another.
6. Write a Program to print all Evan No B/W 1 to 100.
7. Write a program to sum of digits of given integer number
8. Write a program to check given number is prime or not.
9. Write a Program to calculate Sum of digits B/W 1 to 10. For Ex { 1+2+3+4+5+6+7+8+9+10=55}
10. Write A Program to factorial of given which is Entered through the keyboard.
11. Write a program to reverse the any four Digit No.
12. Write a Program to Check that given No is palindrome or Not.
13. Write a Program to print Fibonacci Series. For (0, 1, 1, 2, 3, 5, 8, 13, -------------------)
14. Enter the Ten No through the Keyboard. Write a Program to check (negative, Positive or Zero).
15. Write a program to calculate HCF of Two given number
16. Write a program to enter the numbers till the user wants and at the end it should display the maximum and
minimum number entered.
2
Code Mantra C - Language Assignment Sheet
17. Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the
number is equal to the number itself, then the number is called an Armstrong number.
For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
18. Write a program to calculate the sum of following series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
19. Compute the natural logarithm of 2, by adding up to n terms in the series
1 - 1/2 + 1/3 - 1/4 + 1/5 -... 1/n
where n is a positive integer and input by user.
iv) * v) 1 vi) 1
*** 222 212
***** 33333 32123
******* 4444444 4321234
********* 555555555 543212345
2 Write a program to compute sinx for given x. The user should supply x and a positive integer n. We
compute the sine of x using the series and the computation should use all terms in the series up through
the term involving xn
sin x = x - x3/3! + x5/5! - x7/7! + x9/9! ........
3 Write a program to compute the cosine of x. The user should supply x and a positive integer n. We
compute the cosine of x using the series and the computation should use all terms in the series up
through the term involving xn
cos x = 1 - x2/2! + x4/4! - x6/6! .....
3
Code Mantra C - Language Assignment Sheet
13. C Program to Calculate Sum of all Elements of an Array using Pointers as Arguments
14. C Program to Accept an Array & Swap Elements using Pointers
15. C Program to Read an Array and Search for an Element
16. C Program to Merge and Sort Elements of 2 different Arrays
17. C Program to Sort N Numbers in Ascending Order using Bubble Sort
18. C Program to accept Sorted Array and do Search using Binary Search
19. C Program to find the Biggest Number in an Array of Numbers using Recursion
20. C Program to Compute the Sum of two One-Dimensional Arrays using Malloc
21. C Program to Implement a Queue using an Array
22. C Program to Implement two Stacks using a Single Array & Check for Overflow & Underflow
23. C Program to Generate Pascal Triangle 1 D Array
24. C Program to Print the Number of Odd & Even Numbers in an Array
25. C Program to Print All the Repeated Numbers with Frequency in an Array
26. C Program to Print the kth Element in the Array
27. C Program to Find the Largest Number in an Array
28. C Program to Find the Number of Elements in an Array
29. C Program to Check Array bounds while Inputing Elements into the Array
30. C Program to Merge the Elements of 2 Sorted Array
31. C Program to Input a String & Store their Ascii Values in an Integer Array & Print the Array
32. C Program to Input an Array, Store the Squares of these Elements in an Array & Print it
33. C Program to Print the Alternate Elements in an Array
34. C Program to Find the Odd Element given an Array with only two Different Element
35. C Program to Find the Sum of Contiguous Subarray within a 1 – D Array of Numbers which has the Largest
Sum
36. C Program to Find the Median of the Elements after Merging these 2 Sorted Arrays with Same Size
37. C Program to Find the two Elements such that their Sum is Closest to Zero
38. C Program to Find if a given Integer X appears more than N/2 times in a Sorted Array of N Integers
39. C Program to Segregate 0s on Left Side & 1s on right side of the Array
40. C Program to Find 2 Elements in the Array such that Difference between them is Largest
41. C Program to Find Union & Intersection of 2 Arrays
42. C Program to Find Ceiling & Floor of X given a Sorted Array & a value X
43. C Program to Increment Every Element of the Array by One & Print Incremented Array
44. C Program to Find the Number of Non Repeated Elements in an Array
45. C Program to identify missing Numbers in a given Array
46. C Program to Find the Summation of Node values at Row or Level
Function :-
1. Write a program which input principal, rate and time from user and calculate compound interest. You can
use library function.
CI = P(1+R/100)T - P solution
3. Write a program to check character entered is alphabet, digit or special character using library
functions. solution
4
Code Mantra C - Language Assignment Sheet
6. Write a C++ program to implement the Number Guessing Game. In this game the computer chooses a random
number between 1 and 100, and the player tries to guess the number in as few attempts as possible. Each
time the player enters a guess, the computer tells him whether the guess is too high, too low, or right. Once
the player guesses the number, the game is over.
7. Write a program using function which accept two integers as an argument and return its sum. Call this
function from main( ) and print the results in main( ).
8. Write a function to calculate the factorial value of any integer as an argument. Call this function from main(
) and print the results in main( ).
9. Write a function that receives two numbers as an argument and display all prime numbers between these
two numbers. Call this function from main( ).
10. Raising a number to a power p is the same as multiplying n by itself p times. Write a function called power
that takes two arguments, a double value for n and an int value for p, and return the result as double value.
Use default argument of 2 for p, so that if this argument is omitted the number will be squared. Write the
main function that gets value from the user to test power function. solution
11. Write a function called zero_small() that has two integer arguments being passed by reference and sets the
smaller of the two numbers to 0. Write the main program to access the function.
String program in C language:-
1. C Program to Check if a given String is Palindrome
2. C Program to read two Strings & Concatenate the Strings
3. C Program to Replace Lowercase Characters by Uppercase & Vice-Versa
4. C Program to Count the Number of Vowels & Consonants in a Sentence
5. C Program to Check if the Substring is present in the given String
6. C Program to Accepts two Strings & Compare them
7. C Program to Find the Length of a String without using the Built-in Function
8. C Program to Check if a String is a Palindrome without using the Built-in Function
9. C Program to Find the Frequency of the Word ‘the’ in a given Sentence
10. C Program to Read a String and find the Sum of all Digits in the String
11. C Program to Reverse the String using Recursion
12. C Program to Copy One String to Another using Recursion
13. C Program to find the First Capital Letter in a String using Recursion
14. C Program to find the First Capital Letter in a String without using Recursion
15. C Program to find the Length of the String using Recursion
16. C Program to Check whether a given String is Palindrome or not using Recursion
17. C Program to Check whether two Strings are Anagrams
18. C Program to Count the Occurence of a Substring in String
19. C Program to Remove given Word from a String
20. C Program to Find Highest Frequency Character in a String
21. C Program to Display every possible Combination of two Words or Strings from the input Strings without
Repeated Combinations
22. C Program to Reverse every Word of given String
23. C Program to List All Lines containing a given String
24. C Program to Concatenate two Strings Lexically
25. C Program to Print the Words Ending with Letter S
26. C Program to Find the Sum of ASCII values of All Characters in a given String
5
Code Mantra C - Language Assignment Sheet
17. C program to swap two integer without using temporary variables and bitwise operations
18. C program to find the position of string of 1-bits in a number for a given length
19. C program to check if nth bit in a 32-bit integer is set or not
20. C program to check if a given bit position is set to one or not
21. C program to perform binary addition of string and print it
22. C program to reverse all the bits of an 32-bit integer using
23. C program to count the number of bits needed to be flipped to integer X to generate integer Y
24. C program to count the number of bits set to one using bitwise operations
25. C program to identify the missing number in an integer array of size N-1 with number [1,N]
26. C program to swap two number using bitwise operators-
8
Code Mantra C - Language Assignment Sheet
18.
9
Code Mantra C - Language Assignment Sheet
10
Code Mantra C - Language Assignment Sheet
11