# LABORATORY MANUAL

CS-4205 Programming and Problem Solving Using C

Implementation of C programming problems

SESSION 2009/2011 M.Sc. (CS), M.Sc. (IT) , MCA SEMESTER I

SCHOOL OF COMPUTER SCIENCE & IT, DAVV, INDORE

11. Address and City in different lines. Design and develop solutions to intermediate level problems using the C language. 10. Write a C program to display Your Name. Display the percentage correct to 2 decimal places. Write a C program to display "Hello Computer" on the screen. Write a C program to read in a three digit number produce following output (assuming that the input is 347) 3 hundreds 4 tens 7 units 7. assuming that the input numbers where 20 and 40.Aim: Main aim of this course is to understand and solve logical & mathematical problems through C language and Flowchart. Write a C program to find the area of a circle using the formula: Area = PI * r2 4. 3. C is designed to give C full object-oriented programming capabilities. 9. Typically your output should look like 20 is 50. Its additions to C are mostly based on Smalltalk. Objectives: The C language is a simple computer language designed to enable sophisticated objectoriented programming.Write a C program to swap variable values of i and j.Write a C program to print the multiply value of two accepted numbers 6. Formulas are: Area = 4*PI*R*R Volume = 4/3*PI*R*R*R. Strengthen knowledge of a procedural programming language. Write a C program to convert centigrade into Fahrenheit. Further develop your skills in software development using a procedural language. 2. Write a C program to find the area and volume of sphere.8. and to do so in a simple and straightforward way. 5. Write a C program to find the maximum from given three nos. Formula: C= (F-32)/1. Rema rk Ad m 10-15 Aug 17-22 . one of the first objectoriented programming languages. C is defined as a small but powerful set of extensions to the standard ANSI C language.00% of 40 8. Write a C program to find out whether the character presses through the keyboard is a digit or not (using conditional operator). Most object-oriented development environments consist of several parts:     An object-oriented programming language A library of objects A suite of development tools A runtime environment DESCRIPTION OF SCHEDULE: WEEK 1-8 Aug PRACTICAL LIST 1. Write a C program to read in two integers and display one as a percentage of the other.

Write a C program to find the sum of first 100 odd nos. 21. If the first is lesser print the message up.Write a C program to convert decimal to hexadecimal. 16.Write a C program to display first 100 prime nos. LAB TEST-I 29. 33. 15. 20. 30. print the number day. If the second is lesser. Top left hand corner will show 1x1 and bottom right shows 12x12. 19.Write a C program to find the sum of first 100 natural nos.Write a C program to display first 25 Fibonacci nos. the output should be 288 bec.Write a C program to find that the accepted no is Negative.Write a C program to find factorial of accepted nos. 7-12 Sept . print the message equal if there is an error reading the data. year. if the input is 4. thus.3. print a message containing the word Error. 24. as below.Write a C program to print the accepted no and its reverse no.2. and even nos.Aug 12. 32.Write a C program to find the sum of digits of accepted no. 23.4] 28. print the message down if they are equal. 18.Write a program in C that will scan a number N and then output the sum of the powers from 1 to N.Write a program in C that accepts dates written in numerical form and then output them as a complete form. 25.Write a C program to convert decimal to octal. 13. Positive or Zero. 27. month and year for the next day's date. 1 2 3 4 5 6 7 8 9 10 11 12 2 4 6 8 10 12 14 16 18 20 22 24 3 6 9 12 15 18 21 24 27 30 33 36 4 8 12 16 20 24 28 32 36 40 44 48 5 10 15 20 25 30 35 40 45 50 55 60 6 12 18 24 30 36 42 48 54 60 66 72 7 14 21 28 35 42 49 56 63 70 77 84 8 16 24 32 40 48 56 64 72 80 88 96 9 18 27 36 45 54 63 72 81 90 99 108 10 20 30 40 50 60 70 80 90 100 110 120 11 22 33 44 55 66 77 88 99 110 121 132 12 24 36 48 60 72 84 96 108 120 132 144 24-29 Aug 31 Aug5 Sept 22. Typical input: “28 2 1992” Typical output: “Date following 28:02:1992 is 29:02:1992”.Write a C program for calculator designing using switch /case loop? 17.Write a C program to find HCF of two given numbers. Write a C program to convert decimal to binary.Write a C program to find all the prime number between two given numbers. 1+4+27+256=288 [1. 1986.Produce a multiplication table.Given as input three integers representing a date as day.Write a C program to find LCM of two given numbers.Write a program which reads two integer values. 26. 31.Write a C program that prints the given three integers in ascending order using if – else. month.Write a C program to print all the Factors of accepted no. Sample input: 2 26 1986 Sample output: February 26. 14.

. RICHTER NUMBER (N). b. i. h. 40.5. multiplication.5<=N<6.Write a C program to find minimum. ***** ABCDE * 1 **** ABCD *** 123 *** ABC ***** 12345 ** AB ******* 1234567 * A ********* 123456789 f.Write a program to take a sentence as input and reverse every word of the sentence.Minimum/maximum value from the given input 21-26 Sept 28 Sept -3 oct . c. d..Write C programs to print the terms of each of the following series: i. g.34. subtraction. * 1 A 1 ** 12 AB 23 *** 123 ABC 345 **** 1234 ABCD 4567 ***** 12345 ABCDE 56789 a. sum and average of the given one dimensional array. Cos(x) iii.5-----some damage 5.0<=N<5. n. l. Log (1+x) iv.CHARACTERIZATION N<5. 1 1 A ABCDEDCBA 01 22 AB ABCD DCBA 101 333 ABC ABC CBA 0101 4444 AB AB BA 10101 55555 A A A 37. maximum. Write a C program to perform the basic Matrix operations addition. Transpose. * ABCDE 1 ***** ** ABCD 12 0000 *** ABC 123 *** **** AB 1234 00 ***** A 12345 * k.0---------little or no damage 5.Swapping the values of two variable 44. Display the following output on screen (assuming the value for input parameter n=5) : a. The National Earthquake Information Center has the following criteria to determine the earthquake damages.5----Disaster Higher. Sin(x) ii. i. 39. m. b.---------Catastrophe 14-19 Sept 35.5<=N<7.Write a C Function for the following task 41.Find value of a given Fibonacci term 43. c..---serious damage 6. e-x 36. Here is the given richter scale serve as an input data and the characterization as output information. log(1-x) v. 38. d. ex vi.Calculating Factorial 42.

Fri Mar 17 18:46:47 1995 LAB TEST-II 5-10 oct 48. Print yesterdays date. int isupper(char *s) o. Sin(x) 19-24 oct 50.Write the following recursive C Function oct q. salary. gets and puts function) 53. To return next Date. int mystrend(char *s. int mystrlen(char *s) d. c. int b) int mymod (int a. Nth Fibonacci number s. To return next Year. char *s2) g. delete a record and . Factorial of a given number r. Write User Defined Function and test them in the main program for the following standard function a. Reverse of a give Number u.Write a C program that manipulates the above text file. b. i. d. To return Month name from the date. “DDMMYYYY”. int mypower(int a.Write a c program to create a new data type Date with the help of structure and typedef. char *mysubstr(char *s.45. putch. Here Date is the newly created data type. int abs(int i) l. DD.char *s2) f. address. To return next Month. char *myitoa(int i) c. To add few Months in a date f. “MMDDYY”. To return the date of the week of a given date. 47. char *t) j. int i) h.example of the O/P from my program is. int mystrchr(char *s. Research work. 52. int mystrcmp(char *s1. empname. designation. char *format) i. h. char *old. qualification. city phone? 54. An 46. int myatoi(Char *s) b.42. The program must implements the operation to modify a record. Also write following user defined function for date manipulation. int b) 12-17 49.(using getch. char *mytolower(char*) n. YYYY” 51. char *mystrrev(char *s) i.Write a C program to implement myprintf and myscanf functions using Concept of variable number of arguments. a. int j) e. char *mytoupper(char *) m. char *myreplace(char *s. char *mystrcat(char *s1. Reverse of a given String t. To add few Days in a date e.Write a C program that creates an Employee text file? Records Are empid. The format string can hold the following values: i. “MON. int i. experience. char c. To Display the Date in various format as: Date Display(Date d1. You can use the ANSI standard functions 'time' and 'ctime'. char *new) k. To add few Years in a date g. int islower(char *s) p.

concat source1. • Differentiate local variables from global variables. digits. 26-31 Octo 55.txt source2. other symbols.txt d.txt source3.Write C programs for the following operation to work like DOS Commands: a. Sarita Namdeo Miss. the learner should be able to: • Describe the syntax and semantics of the ANSI C programming language • Explain the use of functions and function decomposition.append new records. • Work in a team to analyze engineering problems and develop C programs for solving these problems. • Investigate the core ANSI C language constructs required to implement C programs • Develop a minor software in C language Lab Instructor: Miss. 61. • Use the basic utilities and facilities for software development in a Unix operating system environment to code.Write a C program to open two files containing integers (in sorted order) and merge their contents.txt source2. compare source1. Sushila Maravi Mr. spaces. type abc. copy source1.txt source2. 58.Write C code to check if an integer is a power of 2 or not 59. copy source1.txt e.txt b. LAB TEST-III Revision and Tutorial 2-7 Nov Learning Outcomes: On completion of this module.txt c. words and lines in a given text file.Write a C program to count the number of vowels.Write a C program to reset a particular bit in a given number.Write a C program to set a particular bit in a given number.txt source4. and state the scope of a variable. Kunal Khandvilkar Miss. consonants.txt source2. Ranu Runuwal Miss Pritika Bahad .txt 56.Write a C program to count bits set in an integer? 60. Rakhi Mulchandani Miss. • debug and test software. 57.