MLR Institute of Technology DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING Computer Programming Lab List of Experiments S.No. Program Category List of Programs 1 Operators a) Write a C program that takes two operands and one operator from the user, performs the operation and then prints the answer (Consider operators +, -, *, and %). b) Write a C program to find the area and volume of sphere. Formulas are: Area = 4*PI*R*R Volume = 4/3*PI*R*R*R. c) Write a C program to find out whether the character pressed through the keyboard is a digit or not (using conditional operator). d) Write a C program to print logic 1 if input character is capital otherwise 0. e) Write a C program to display 1 if input number is between 1 to 100 otherwise 0 by using the logical AND operator. f) Write a C program to shift the input data by two bits right. g) Write a C program to swap the values of two variables with/without using a third variable. h) Write a C program to add the individual digits of a 3-digit number by % and / operator. 2 Control Statements a) Write a C program to to print the given 3 integers in ascending order using if-else. b) Write a C program to calculate commission for the input value of sales amount. Commission is calculated as per the following rules: Commission is nil for sales amount Rs 5000/. Commission is 2% for sales when sales amount is greater than 5000 and less than equal to 10000. Commission is 5% for sales amount greater than 10000. c) A character is entered through keyboard. Write a C program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol using if-else and switch case. 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 d) Write a C program to examine a character entered from the keyboard is a lowercase letter or upper case, digit, punctuation mark or a space character. e) Write a C program to read a 3 digit number from keyboard and print it vertically using if-else. f) Write a C program to check whether a given 3 digit number is Armstrong number or not using if-else. g) Write a C program to read a week day number (0 to 6) and print the day name. h) Write a C program to provide multiple functions such as ADD, SUB, MUL, DIV and MOD using switch case. i) If cost price and selling price of an item s input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Write a C program to determine how much profit or loss incurred in percentage. j) Write a C program to find Sum of individual digits of a positive integer. k) Write a C program to generate to generate the first n terms of the Fibonacci sequence. l) Write a C program to generate all the prime numbers between 1 and n, where n is a value supplied by the user. m) Write a C program to check the given number is perfect number or not. n) Write a C program to print the factors of a given number. o) Write a C program to calculate the following sum, Sum=1 + x2/2! + X4/4! up to given n terms. p) Write a C program to find the roots of a quadratic equation. q) Write a C program to generate Pascal s triangle. r) Write a C program to find the GCD and LCM of two numbers. s) The total distance traveled by vehicle in t seconds is given by distance=ut+1/2at2 where u and a are the Initial velocity (m/sec) and acceleration (m/sec2). Write a C program to find the distance traveled at regular intervals of time given values of u and a. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different values of u and a. t) Write a C program to find the largest and smallest number in a list of integers. u) Write a C program to read in two numbers, x and n, and then compute the sum of this geometric progression 1+x+x2+x3+...xn. For example: if n is 3 and x is 5, then the
program computes 1+5+25+125. 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 nest pair of numbers of without computing the sum. Are any values of x also illegal? If so, test for them too. v) Write a C program to print the numbers in triangular form 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 w) Write a C program to find friendly numbers between 1 to n. x) Write a C program to print the perfect squares between 1 to 100. y) Write a C program to print the following series 1/1! + 2/2! + 3/3! + z) Write a C program to generate all combinations of 1, 2 and 3 numbers using for loop. 3 Functions a) Write a C program to find the factorial of a given number using non-recursive and recursive function. b) Write a C program to find the GCD (greatest common divisor) of two given integers using non-recursive and recursive function. c) Write a C program to Convert decimal number to binary number Convert Binary number to decimal number Using non recursive functions. d) Write a C program to print your name using recursion. e) Write a C program to print Fibonacci series using recursion. f) Write a C program to solve Towers of Hanoi problem using recursive function. g) Write a C program to print the transpose of a given matrix using function. h) Write a C program that will print the longest word written in a line using function. i) Write a C program that uses a function to search a number within an array. j) Write a C program that uses a function to scan a string that is passed as an argument and convert all characters to capital letters. k) Write a C program that uses a function to reverse a given string and use it to check whether the given string is a palindrome or not.
4 Arrays a) Write a C program to find minimum, maximum, sum and average of the given one dimensional array. b) Write a C program to print the alphabets A Z along with their ASCII values using array. c) Write a C program to store numbers into an array and find the frequency of a particular number in array and print it. d) Write a C program to count and display positive, negative, odd and even numbers in an array. e) Write a C program to find the largest and smallest number in a list of integers. f) Write a C program to swap the K th and (K+1) th elements in an integer array. K is given by the user. g) Write a C program to merge two sorted arrays into another array in a sorted order. h) Write a C program to print the individual digits of a number using array. i) Write a C program to print the binary equivalent of a given decimal number using array. j) Write a C program to search a given element n present in the array or not. k) Write a C program to sort the array elements in ascending order using bubble sort technique. l) Write a C program to convert a Roman letter into its decimal equivalent. m) Write a C program to find 2 s complement of a binary number. n) Write a C program to read a matrix of size mxn and print it. o) Write a C program that uses functions to perform the following Addition of two Matrices Multiplication of two Matrices 5 Pointers a) Write a C program to add two numbers using pointers. b) Write a C program to swap two numbers using pointers. c) Write a C program to find the length of string using pointers. d) Write a C program to compare two strings using pointers. e) Write a C program to copy a string from source to destination using pointers. f) Write a C program to reverse a string using pointers. 6 Strings a) Write a C program to find the length of a given string. b) Write a C program to count the number of vowels in a given string and also print the vowels. c) White a C program to check how many alphabets and non alphabets are there in a string. d) Write a C program to remove blank spaces from a string. e) Write a C program to capitalize all the letters of a string. f) Write a C program that uses functions to perform the following
operations To insert a sub-string in to given main string from a given position. To delete n characters from a given position in given string. g) Write a C program to determine if the given string is a palindrome or not. h) Write a C program that displays the position or index in the string S where the string T begins or 1 if S does not contain T. i) Write a C program to count the lines, words and characters in a given text. j) Write a C program that deletes a word from a sentence. Note that the word may appear any number of times. k) Write a C program to find a string within a sentence and replace it with another string. l) Write a C program that takes the name of a person as input and prints the name in an abbreviated fashion, e.g. Ram Kumar as R. K. m) Write a C program that reads a line of text and counts all occurrence of a particular word. n) Write a C program to convert each character of a string into the next alphabet and print the string. 7 Structures and Unions a) Write a C program to copy one structure to another of same type. b) Write a C program that passes a pointer to a structure and returns nothing. c) Write a C program to define a structure named time, which contains three int members. d) Write a C program to create a structure containing 5 strings: address1, address2, city, state and zip. Create a typedef called record that can be used to create instances of this structure. e) Write a C program that uses functions to perform the following operations Reading a complex number Writing a complex number Addition of 2 complex numbers Multiplication of 2 complex numbers 8 Files a) Write a C program to copy the contents from one file to another. b) Write a C program to display the contents of a file on screen. c) Write a C program to count the number of characters and number of lines in a file. d) Write a C program that accepts the names of two files. It
should copy the first file into the second line by line. Use the fgets() and fputs() functions. e) Write a C program to delete a file using remove() function. f) Write a C program to rename the old file name to new file name using rename(). g) Write a C program to reverse the first n characters in a file. (Note: the file name and n are specified on the command line) h) Write a C program to find the no. of characters, no. of words, and number of lines in a given file.