ECE List of Experiments
ECE List of Experiments
List of Experiments:
2. Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0 and
1. Subsequent terms are found by adding the preceding two terms in the sequence.
4. Write a C program to generate all the prime numbers between 1 and n, where n is a value
7. Write a C program to find the GCD (greatest common divisor) of two given integers.
9. Write a C program, which takes two integer operands and one operator from the user, performs
the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch
Statement)
10. Write a C program to find both the largest and smallest number in a list of integers.
12. Write a C program that uses functions to perform the following operations:
14. Write a C program that displays the position or index in the string S where the string T begins, or
– 1 if S doesn’t contain T.
15. Write a C program to count the lines, words and characters in a given text.
18. Write a C program to read in two numbers, x and n, and then compute the sum of this geometric
progression:
Print x, n, the sum Perform error checking. For example, the formula does not make sense for negative
exponents – if n is less than 0.
Have your program print an error message if n<0, then go back and read in the next pair of
numbers of without computing the sum. Are any values of x also illegal ? If so, test for them too.
19. 2’s complement of a number is obtained by scanning it from right to left and complementing all
the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C
21. Write a C program that uses functions to perform the following operations:
22
(Note: The file name and n are specified on the command line.)
23
24. Write a C program that implements the following sorting methods to sort a given list of integers in
25. Write C programs that use both recursive and non recursive functions to perform the following
List of Experiments:
2. Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0
and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write
3. Write a C program to generate all the prime numbers between 1 and n, where n is a value
6. Write a C program to find the GCD (greatest common divisor) of two given integers.
8. Write a C program, which takes two integer operands and one operator from the user,
performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use
Switch Statement)
9. Write a C program to find both the largest and smallest number in a list of integers.
11. Write a C program that uses functions to perform the following operations:
13. Write a C program that displays the position or index in the string S where the string T begins,
or – 1 if S doesn’t contain T.
14. Write a C program to count the lines, words and characters in a given text.
17. Write a C program that uses functions to perform the following operations:
18.
(Note: The file name and n are specified on the command line.)
19.
ii. Write a C program to merge two files into a third file (i.e., the contents of the first file
20. Write a C program that uses functions to perform the following operations on singly linked
list.:
23. Write a C program that implements the following sorting methods to sort a given list of
integers in ascending order i) Bubble sort ii) Selection sortiii)Insertion sort
24. Write C programs that use both recursive and non recursive functions to perform the following
Practice sessions:
a. Write a simple program that prints the results of all the operators available in C (including pre/
post increment , bitwise and/or/not , etc.). Read required operand values from standard input.
b. Write a simple program that converts one given data type to another using auto conversion and
a. Write a program for finding the max and min from the three numbers.
c. Write a program that declares Class awarded for a given percentage of marks, where mark
<40%= Failed, 40% to <60% = Second class, 60% to <70%=First class, >= 70% = Distinction.
d. Write a program that prints a multiplication table for a given number and the number of rows in
the table. For example, for a number 5 and rows = 3, the output should be:
5x1=5
5 x 2 = 10
5 x 3 = 15
e. Write a program that shows the binary equivalent of a given positive number between 0 to 255.
Expression Evaluation:
a. A building has 10 floors with a floor height of 3 meters each. A ball is dropped from the top of
the building. Find the time taken by the ball to reach each floor. (Use the formula s = ut+(1/2)at^2
where u and a are the initial velocity in m/sec (= 0) and acceleration in m/sec^2 (= 9.8 m/s^2)).
b. Write a C program, which takes two integer operands and one operator from the user, performs
the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch
Statement)
c. Write a program that finds if a given number is a prime number
d. Write a C program to find the sum of individual digits of a positive integer and test given number
is palindrome.
e. A Fibonacci sequence is defined as follows: the first and second terms in the sequence are 0
and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write
f. Write a C program to generate all the prime numbers between 1 and n, where n is a value
i. 1-x/2 +x^2/4-x^3/6
j. Write a C program to read in two numbers, x and n, and then compute the sum of this geometric
computes 1+5+25+125.
a. Write a C program to find the minimum, maximum and average in an array of integers.
(iii) Transpose of a matrix with memory dynamically allocated for the new matrix as row and column
e. Write a program for reading elements using a pointer into an array and display the values using
the array.
f. Write a program for display values reverse order from an array using a pointer.
Files:
b. Write a C program which copies one file to another, replacing all lowercase characters with
c. Write a C program to count the number of times a character occurs in a text file. The file name
It should first create a binary file and store 10 integers, where the file name and 10 values are given in
the command line. (hint: convert the strings using atoi function) Now the program asks for an index and
a value from the user and the value at that index should be changed to the new value in the file. (hint:
use fseek function) The program should then read all 10 values and print them back
e. Write a C program to merge two files into a third file (i.e., the contents of the first file followed
Strings:
a. Write a C program to convert a Roman numeral ranging from I to L to its decimal equivalent.
f. Write a C program to determine if the given string is a palindrome or not (Spelled same in both
directions with or without a meaning like madam, civic, noon, abcba, etc.)
g. Write a C program that displays the position of a character ch in the string S or – 1 if S doesn‘t
contain ch.
h. Write a C program to count the lines, words and characters in a given text.
Miscellaneous:
a. Write a menu driven C program that allows a user to enter n numbers and then choose between
finding the smallest, largest, sum, or average. The menu and all the choices are to be functions.
Use a switch statement to determine what action to take. Display an error message if an invalid
choice is entered.
1 1 1
12 23 22
* *
** **
*** ***
**
a. Write a C program that uses non recursive function to search for a Key value in a given
c. Write a C program that uses non recursive function to search for a Key value in a given
e. Write a C program that implements the Bubble sort method to sort a given list of
g. Write a C program that sorts the given array of integers using selection sort in descending order
h. Write a C program that sorts the given array of integers using insertion sort in ascending order