Sunteți pe pagina 1din 6

LAB ASSIGNMENTS INTRODUCTION TO COMPUTING LAB Subject Code: CS 291 Day 1 Fundamentals of Computers Elementary DOS commands Using

ing the Turbo C Environment Day 2: C Fundamentals Lab a!!"#$%e$t! 1. Write a program to find the maximum and minimum of three numbers taken from the user. 2. Write a program that reads three integer numbers. Check whether these numbers can be considered as the three sides of a triangle. If so, find the type (isosceles, e uilateral or right!angled" and area of the triangle. &o%e a!!"#$%e$t! 1. Consider a currency system in which there are notes of se#en denominations, namely, $e.1, $s. 2, rs.%, $s.1&, $s. %& and $s. 1&&. If a sum of $s. ' is entered through the keyboard, write a program to compute the smallest number of notes that will combine to gi#e $s. '. 2. If a number ()2 is entered through the keyboard, write a program that should print 'I'* +*,*' -W.. /. Write a program to find out how many days and how many weeks ha#e passed between the dates &10&102&&1 to today. 2. Write a program to compute 3, the amount accrued at the end of 4n5 years, on a principal amount of 6 rupees, where the rate of interest is 4r5 using the compound interest formula7 3 8 6(1 9 r"n. %. Write a program to find the roots (real and imaginary" of the uadratic e uation of the form ax2 9 bx 9 c 8 &. Day ': Control Structures I Lab a!!"#$%e$t! 1. Write a program to count the occurrences of a gi#en number in a set of n numbers (n to be taken as input". 2. Write a program to con#ert a decimal number to its binary e ui#alent and #ice!#ersa. &o%e a!!"#$%e$t! 1. -he e uation x2 9 y2 8 r2 represents a circle which centre at origin and radius r. Write a program that reads r from the keyboard and prints the no of points with integer coordinates that lie on the circumference of the circle. 2. -he nos. in the se uence & 1 1 2 / % 1 1/ 21 (((() are called :ibonacci nos. Write a program to print the first n (to be taken as input" :ibonacci nos. /. + uare of 12 is 122. 21, which is the re#erse of 12 has a s uare 221, which is same as the re#erse of 122. Write a program to find out all such nos. in the range 1& to 1&&. 2. Write a program to generate the following pyramid! 1 2/2 /2%2/ 2%;);%2 ((((((()) %. Write a program that, for all positi#e integers i, <, k and m from 1 through 1&&, finds and prints all combinations of i, <, k and m such that i 9 < 9 k 8 m and i = < = k = m. Day *

Control Structures II Lab a!!"#$%e$t! 1. Write a program to obtain the sum of the n terms (n to be taken from user" of the following series x/0/? 9 x%0%? ! @@@ 2. Write a program to print each of the following output patterns 1 22 /// 2222 %%%%% (((() AAAAA AAAA AAA AA A

x>

&o%e a!!"#$%e$t! 1. Write a program to print the following 6ascal5s -riangle 1 1 1 1 2 1 1 / / 1 1 2 ; 2 1 1 % 1& 1& % 1 ()))() (((() 2. Write a program to find all 3rmstrong numbers in the range 1 to B, where B is taken as input. /. Write a program to find the number of digits in a number entered through the keyboard. 3lso find the sum of the digits of that number and check whether that number is a palindrome or not. /. 3 positi#e integer is entered through the keyboard. 3long with it the base of the number system in which you want to con#ert this number is entered. Write a program to do this con#ersion. 2. Write a program to display the number table of any integer entered through the keyboard. Day +: One Dimensional Arrays Lab a!!"#$%e$t! 1. Write a program to find the a#erage of the elements of an integer array. 3lso find the standard de#iation of these elements. 2. Write a program to sort a set of n numbers in descending order and then search for a gi#en number (taken from user" in the set of sorted numbers. &o%e a!!"#$%e$t! 1. Write a program that displays the day of the year for an input date. :or example for an input 2( 1& 1(2( the program will gi#e the output -uesday, .ctober 2(, 1(2(. 2. Write a program to print a histogram of the fre uencies of different characters present in a character array entered through keyboard. /. Write a program to insert an element (gi#en by the user" into an array in a particular position (gi#en by the user". 2. Write a program to delete an element from a particular position (gi#en by the user" in an array. %. Write a program to find the maximum and second maximum of a set of numbers.

Day ,: Multidimensional Arrays Lab a!!"#$%e$t! 1. Write a program to find the transpose of a matrix. 2. Write a program to multiply two matrices. &o%e a!!"#$%e$t! 1. Write a program to find whether a matrix is orthogonal or not. 3lso find the norm of the matrix. 2. Write a program to find the in#erse of a matrix. /. Write a program to find whether a gi#en matrix is upper triangular or lower triangular. 2. Write a program to find the difference, in days, between a date entered by the user and today5s date. %. Write a program to accept the maximum temperature of % different cities in ) days of a week. Calculate the a#erage temperature of each city and display the name of the cities along with their a#erage temperatures in order of their temperatures. Day -: String Handling Lab a!!"#$%e$t! 1. Write a program to (a" compare two gi#en strings (b" concatenate two gi#en strings without using standard library functions. 2. Write a program to (a" re#erse a gi#en string (b" check whether a gi#en string is palindrome or not without using standard library functions. &o%e a!!"#$%e$t! 1. Write a program to read a line of text from the keyboard and con#ert it into a coded text by changing its characters by adding a code number to them. -his code number must be taken as input. 2. Write a program to read in a line of text and count the number of blank spaces, tabs and new lines in that line. 3lso rewrite the line of text with tabs and new lines replaced by the #isible se uences 4Ct5 and 4Cn5. /. Write a program to read in a line of text and count the number of lines, words and characters in that text. 2. Write a program to input a number of names and sort them alphabetically. %. Write a program to count the number of #owels and digits in a gi#en string. Day .: Functions Lab a!!"#$%e$t! 1. Write a menu!dri#en program to (c" calculate the factorial of a gi#en number (d" check whether the number is prime or not (e" check whether the number is a palindrome or not Dse different functions for each of the abo#e tasks and call the functions from main ( " using switch statement. 2. Write a program to find the maximum and minimum elements of an array using two different functions arrayBax ( " and arrayBin ( ".

&o%e a!!"#$%e$t! 1. Write a function myClrscr ( " that simulates the clrscr ( ". Call this function from main ( ". 2. -he first difference E1 of a se uence 3 of ' elements is obtained by subtracting each element, except the last, from the next element in the array. -he second difference E2 is defined as the first difference of E1, and so on. :or example, if 3 7 1, 2, 2, ), 11, 1;, 22 then E1 7 1, 2, /, 2, %, ; E2 7 1, 1, 1, 1, 1 E/ 7 &, &, &, & Write a function findEifference ( " that takes as argument an array of n elements and finds its first, second and third differences. Write a main ( " to call findEifference ( ". /. Write functions to add, subtract and multiply two complex numbers (a 9 ib" and (x 9 iy". Write a main ( " to test the functions. 2. Write fi#e user defined functions which perform the tasks of strlen ( ", strcmp ( ", strcpy ( ", strre# ( ", strcat ( ". Write a main ( " to test these functions. %. Write a program to find whether a matrix is symmetric or not using a function is+ymmetric ( ". Day 9: Recursion Lab a!!"#$%e$t! 1. Write a recursi#e function to calculate the gcd of two numbers. 2. Write a recursi#e function to print the first n :ibonacci numbers. &o%e a!!"#$%e$t! 1. Write a recursi#e function to e#aluate nCr 8 n? 0 r? A (n > r"? 2. Write a recursi#e function to con#ert a decimal integer, taken as input, to its hexadecimal e ui#alent. /. :ind the sum of the series 1 9 x 9 x202? 9 x/0/? 9 @@@@, using a recursi#e function. 2. :ind the maximum and minimum of a list of numbers using a recursi#e function. %. Write a recursi#e function to calculate the sum of all digits of a number entered by the user. Day 1/: Pointers Lab a!!"#$%e$t! 1. Write a program to sort a list of elements, using pointers and dynamic memory allocation. 2. Write a program, using pointers, that accepts a string and con#erts all its characters to upper or lower case. It uses the functions toupper ( " and tolower ( " defined in ctype.h. &o%e a!!"#$%e$t! 1. Write an interacti#e C program, using pointers, which will encode a line of text. -o encode a line of text, proceed as follows7 Con#ert each character, including blank spaces, to its 3+CII e ui#alent Fenerate a positi#e random integer. 3dd this integer to the 3+CII e ui#alent of each character. -he same random integer will be used for the entire line of text +uppose that '1 represents the lowest permissible #alue in the 3+CII code, and '2 represents the highest permissible #alue. If the number obtained in step 2 abo#e (i.e., the original 3+CII e ui#alent plus the random integer" exceeds '2, then subtract the largest possible multiple of '2 from this number, and add the remainder to '1. Gence the encoded number will always fall between '1 and '2, and will therefore always represent some 3+CII character Eisplay the characters that correspond to the encoded 3+CII #alues.

2. Write a program to multiply two matrices using array of pointers. /. Write a program to find the maximum and minimum elements of a matrix, using array of pointers 2. Write an interacti#e C program that will accept the name of a country as input and display the corresponding capital, and #ice!#ersa. Eesign the program so that it executes repeatedly, until the word *'E. Write the program using pointer notation. %. Write three functions, using pointers, to concatenate two strings, to compare two strings and to re#erse a string, respecti#ely. -est these functions in a complete program. Day 11: Pointers Lab a!!"#$%e$t! 1. Write a program, using dynamic memory allocation, to find the a#erage of n numbers, where n is to be entered at the command line. 2. Write a program to add two tables of numbers where the number of rows and columns are gi#en at the command line. &o%e a!!"#$%e$t! 1. Write a function that takes as arguments, three pointers to integer numbers, finds the maximum among them and returns a pointer to the maximum integer. -est the function in a complete program. 2. Implement your own #ersion of gets ( " and puts ( " function. -he gets ( " function returns a pointer to character and takes an argument, a character array. -he function reads in a line from stdin, placing it in the array and terminating it with a null character. -he newline is used to terminate the input line. -he newline is not itself stored in the array. -he function returns the address of the array. If an error or *.: occurs, the function returns null. -he puts ( " function takes one argument, a string to be sent to stdout as a single line. 3fter the function writes the string, it writes a newline. /. Write a program in which a pointer to a function accepts three pointers to integer uantities as arguments and returns the sum of those three integer uantities to a floating point uantity. 2. Write a complete C program, using pointer notation, that will generate a table containing the following three columns7 t aexp(bt" sin(ct" aexp(bt"cos(ct" +tructure the program in the following manner7 write two special functions, f1 and f2, where f1 e#aluates the uantity aexp(bt" sin(ct" H f2 e#aluates aexp(bt"cos(ct". Ga#e main enter the #alues of a, b and c, and then call a function, tableIgen, which will generate the actual table. 6ass f1 and f2 to tableIgen as arguments. -est the program using the #alues a82, b8!&.1, c8&.% where the #alues of t are 1, 2, /,@., ;&. %. Write a program to sort a list of strings, entered at the command line.

Day 12: Structures and Unions Lab a!!"#$%e$t! 1. Eefine a structure named JstudentK to store information of a student (roll, name, marksIn6hysics, marksInChemistry, marksInBathematics". Write a program, which will take as input the roll, name and numbers obtained by se#eral students in different sub<ects. -he program will calculate the total marks obtained by each student and display the list of students in descending order according to the total marks. 2. Eefine a structure named JemployeeK to store information of an employee (emp'o, name, department, basic6ay, E3, G$3 and gross+alary". Write a program, which will take as input the emp'o, name, department, basic6ay for se#eral employees. -he program will calculate the E3, G$3 and total for each employee and display the details of the employee ha#ing the highest gross salary.

&o%e a!!"#$%e$t! 1. 3 factory producing alloys like brass, bronLe and stainless steel, wants to keep record of the composition of the metals produced. Mrass is an alloy of copper and tin. +tainless is produced by adding right uantity of nickel and chromium. -he factory wants to keep information about se#eral alloys. Write a program using structure and union to efficiently store these information. 2. Write a program by using structure that describes the set books in a library. :or each book the members are name of author, publisher, price and branch information. -he program should (i" print the list of books supplied by a publisher (ii" print the list of books in a particular branch /. Write a program which will calculate income tax and total tax for se#eral persons at following rates7 (a" taxable income up to 2&,&&& > no tax (b" taxable income from 2&,&&1 to ;&,&&& > income tax 8 /&&& 9 &./ (taxable income > 2&,&&&" (c" taxable income from ;&,&&1 to 1,2&,&&& > income tax 8 ;&&& 9 &./ (taxable income > 2&,&&&" (d" taxable income o#er 1,2&,&&& > income tax 8 12,&&& 9 &./ (taxable income > 2&,&&&" Calculate the tax payable by a person using the abo#e scheme. -he program should accept pan'o, name, address, taxable income and tax payable and print the details of the persons who ha#e a tax of 1%,&&& and abo#e. 2. Write a program to calculate the monthly interest to be payable to the fixed deposit holders of a bank at the following rates7 Pe0"od o1 De2o!"t Rate o1 I$te0e!t Bore than % years 12N O/ > % years 11N O1 ! / years 1&N O; months > 1 year 1N %. -he time at a gi#en point has three elements hours, mins and secs. Write a program to add two times. Dse a function to add the times and return result. Day 1': File Handling Lab a!!"#$%e$t! 1. Write a program to create a file named JinfoK to store the roll number and marks obtained in physics, chemistry and mathematics by se#eral students. -hen the program should take input from the file JinfoK and find the total marks obtained by each student and write all these information (roll number, physics, chemistry, mathematics and total marks" in another file named JresultK. 2. Write a program named copyfile.c, which will imitate the E.+ JcopyK command to copy the contents of a source file to a destination file. -he names of both files are to be supplied from the command line. &o%e a!!"#$%e$t! 1. Write a program to create a text file containing records of the students of a class. -he records include student name, branch and roll number. Pou program must include the pro#ision for adding, deleting and searching records. 2. Write a program to count the number of lines, words and characters in a gi#en file. /. Write a program to display the fre uency of characters in a gi#en file. 2. Write a program to compare two files and print the lines where they differ. %. Write a program that will recei#e a file name and a line of text from the command line and write the text to the file.

S-ar putea să vă placă și