0% found this document useful (0 votes)
78 views

Ode Antra: C - Language Assignment Sheet

The document provides a list of programming assignments for learning basic and advanced C language concepts. It includes over 50 assignments grouped into the following categories: basic C language assignments, decision control systems, loop programs, arrays, mathematical series, and geometric patterns. The assignments involve input/output, conditional statements, loops, functions, arrays, strings and other C programming fundamentals.

Uploaded by

Juni Indore
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Ode Antra: C - Language Assignment Sheet

The document provides a list of programming assignments for learning basic and advanced C language concepts. It includes over 50 assignments grouped into the following categories: basic C language assignments, decision control systems, loop programs, arrays, mathematical series, and geometric patterns. The assignments involve input/output, conditional statements, loops, functions, arrays, strings and other C programming fundamentals.

Uploaded by

Juni Indore
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Code Mantra C - Language Assignment Sheet

Basic C language Assignment :-


1. Write a Program to Print Hello?
2. Write a program to print “Hello”? (hint:- Escape Sequence)
3. Write a program to Perform Addition Of two No Entered through the Keyboard.
4. Write a Program to calculate Simple Interest for any Principle Amount.
5. Write a Program to Find the calculate the Average of five Subject marks.
6. Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and
house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
7. Write a Program to calculate the area of Circle and Rectangle.
8. Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this
temperature into Centigrade degrees.
9. Two numbers are input through the keyboard into two locations C and D. Write a program to interchange
the contents of C and D.
10. Enter the four Digit no through the Keyboard ? write a program to find the sum of its first and last Digit.
11. Enter the four Digit no through the Keybord ? write a program to find the sum of its Middle two Digit.
12. Enter the four Digit no through the Keybord ? write a program to find the sum of its all digits.
13. Enter the four Digit no through the Keybord ? write a program to revrse the No.
14. If a five-digit number is input through the keyboard, write a program to print a new number by adding one
to each of its digits. For example if the number that is input is 12391 then the output should be displayed as
23402.
15. A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input
through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier
will have to give to the withdrawer.
Decision Control System:-
1. Write a C program to print the number entered by user only if the number entered is negative.
2. Write a C program to check whether a number entered by user is even or odd
3. Write a program find the percentage of five subject marks. If percentage is grater then or equal to 50 then
print pass otherwise Print Fail.
4. Write a program to find the weather it is leap year or Not.
5. While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000. If
quantity and price per item are input through the keyboard, write a program to calculate the total expenses.
6. The marks obtained by a student in 5 different subjects are input through the keyboard. The student gets a
division as per the following rules:
Percentage above or equal to 60 - First division
Percentage between 50 and 59 - Second division
Percentage between 40 and 49 - Third division
Percentage less than 40 - Fail
Write a program to calculate the division obtained by the student.
7. A company insures its drivers in the following
cases:
− If the driver is married.
− If the driver is unmarried, male & above 30 years of age.
− If the driver is unmarried, female & above 25 years of age.
In all other cases the driver is not insured. If the marital status, sex and age of the driver are the inputs, write
a program to determine whether the driver is to be insured or not.
8. A five-digit number is entered through the keyboard. Write a program to obtain the reversed number and to
determine whether the original and reversed numbers are equal or not.

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.

Write a program to print following :

i) ********** ii) * iii) *


********** ** **
********** *** ***
********** **** ****
***** *****

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! .....

Program for Array


1. C Program to Calculate Sum & Average of an Array
2. C Program to Find the Largest Two Numbers in a given Array
3. C Program to Calculate the Sum of the Array Elements using Pointer
4. C Program to Put Even & Odd Elements of an Array in 2 Separate Arrays
5. C Program to Insert an Element in a Specified Position in a given Array
6. C Program to Cyclically Permute the Elements of an Array
7. C Program to Sort the Array in an Ascending Order
8. C Program to Sort the Array in Descending Order
9. C Program to Find the Second Largest & Smallest Elements in an Array
10. C Program to Delete the Specified Integer from an Array
11. C Program to Split an Array from Specified Position & Add First Part to the End
12. C Program to Sort Names in an Alphabetical Order

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

2. Write a program to compute area of triangle. Sides are input by user.


Area = sqrt(s*(s-a)*(s-b)*(s-c))
where s=(a+b+c)/2. solution

3. Write a program to check character entered is alphabet, digit or special character using library
functions. solution

4. Write a program which display a number between 10 to 100 randomly.solution

4
Code Mantra C - Language Assignment Sheet

5. Write a program which accept a letter and display it in uppercase letter.

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

27. C Program to find Longer Repeating Sequence


28. C Program to Replace all the Characters by Lowercase
29. C Program to Count the Total Number of Words in the Sentence using Command Line Argument
30. C Program to Insert Character/Word in any Desired Location in a String
31. C Program to Find the First Occurence of the any Character of String2 in String1
32. C Program to Implement Regular Expression Matching
33. C Program to Implement strpbrk() Function
34. C Program to Sort the String and Repeated Characters should be present only Once
35. C Program to Find the Length of the Longest Repeating Sequence in a String
36. C Program to Count the Number of Unique Words
37. C Program to find the possible subsets of the String
38. C Program to Search a Word & Replace it with the Specified Word
39. C Program to find First and Last Occurrence of given Character in a String
40. C Program to Display the Characters in Prime Position a given String
41. C Program to Find All Possible Subsets of given Length in String
42. C Program to Delete All Repeated Words in String
43. C Program to Count Number of Words in a given Text Or Sentence
44. C Program to Find the Frequency of Substring in the given String
45. C Program to Find the Frequency of Every Word in a given String
46. C Program to Sort Word in String
47. C Program To Print Smallest and Biggest possible Word which is Palindrome in a given String
48. C Program to Print Combination of two Words of two given Strings without any Repetition
49. C Program to Sort String Ignoring Whitespaces and Repeating Characters Only Once
50. C Program to Reverse the String using Both Recursion and Iteration
51. C Program to Display Every Possible Combination of Two Words from the given 2 String without Displaying
Repeated Combinations
52. C Program to Accept 2 String & check whether all Characters in first String is Present in second String & Print
53. C Program to Check whether a given Character is present in a String, Find Frequency & Position of Occurrence
54. C Program to Count the Number of Occurrence of each Character Ignoring the Case of Alphabets & Display
them
55. C Program to Count the Occurrences of each C Keyword using Array Structure
56. C Program to Determine if One String is a Circular Permutation of Another String
57. C Program to Find the Consecutive Occurrence of any Vowel in a String
58. C Program to Find the Largest & Smallest Word in a String
59. C Program to Find the Most/Least Repeated Character in the String
60. C Program to Implement the KMP Pattern Searching Algorithm
61. C Program to Input 2 Binary Strings and Print their Binary Sum
62. C Program to Input a String with at least one Number, Print the Square of all the Numbers in a String
63. C Program to Remove all Characters in Second String which are present in First String
64. C Program which Converts an Integer to String & vice-versa
65. C program that takes input as 2323 and gives output as 2332. ie. the new number should be greater than the
previous number but should have the same digits.
File Handling :
1. C Program to Create a File & Store Information
2. C Program to Illustrate Reading Of Data From a File
3. C Program to Delete a Specific Line From a Text File
4. C Program to Replace a Specific Line In a Text File
5. C Program to Find the Number Of Lines in a Text File
6. C Program to Append The Content Of File at The end Of Another
7. C Program that Merges Lines Alternatively From 2 F File & Print Result
6
Code Mantra C - Language Assignment Sheet

8. C Program to Display the Function Names Defined In Source File


9. C Program to Capitalize First Letter Of Every Word in a File
10. C Program to Copy File into Another File
11. C Program to Create Employee Record and Update it
12. C Program to Convert the Content of File to UpperCase
13. C Program to Replace First Letter Of Every Word With Capital Letter
14. C Program to Reverse The Contents Of a File and Print it
15. C Program to Convert the Content Of File to LowerCase
16. C Program to Update Details Of Employee Using Files
17. C Program to Join Lines Of Two given Files and Store them in a New File
Structure:
1. Store Information (Name, Roll And Marks) Of A Student Using Structure
2. Store Information Of 10 Student Using Structure
3. C Program To Create, Declare And Initialize Structure
4. C Program To Read And Print An Employee’s Structure
5. C Program To Demonstrate Example Of Nested Structure
6. C Program To Demonstrate Example Structure Pinter (Structure With Pointer)
7. C Program To Add Two distance in feet and inches using structure
8. C Program for passing structure as functions arguments and returning a structure from a function
Dynamic Memory Allocation :
1. C Program To Create memory for int, char and float variable at run time
2. C Program To input and print text using dynamic memory allocation
3. C Program To read a one dimensional array, print sum of all elements along with inputted array
element using dynamic memory allocation
4. C Program To read and print the student details using structure and dynamic memory allocation
5. C Program To read and print the N student details using structure and dynamic memory allocation
6. C Program To find maximum and minimum value using malloc
7. C program to calculate average of five subject using malloc input value on run time
Bitwise Operator :
1. C program to check whether the given integer has an alternative pattern
2. C program to round floor of integer to next lower power of 2
3. C program that uses function to return MSB position of unsigned integer
4. C program to use bitwise operations to round (floor of) an integer to next lower multiple of 2
5. C program to print the range of fundamental data type
6. C program to check if all the bits of a given integer is one (1)
7. C program to find next higher value of N with same 1’s
8. C program to count the number of trailing zeroes in integer
9. C program to use bitwise operations to count the number of leading zero’s in a number X
10. C program to find the highest bit set for any given integer
11. C program to count number of bits set to 0 in an integer
12. C program to replace bits in integer from specified positions from another integer
13. C program to replace bits in integer X from bit position a to b form another integer
14. C program to takes byte as input and returns all the bits between given positions
15. C program to swap the ith and jth bits for a 32- bit integer
16. C program to check if a given integer is power of 2 using bitwise operation
7
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

You might also like