cs 4205 programming&problemsolvingusingc

Upload: amitjajoo

Post on 02-Jun-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    1/6

    LABORATORY MANUAL

    CS-4205 Programming and Problem Solving Using C

    July 2012 Onwards

    Devi Ahilya Vishwavidyalaya

    School of Computer Science & IT

    We makethings happen . . .

    Producing worldclass

    IT Professionals

    Since 1986

    www.scs.dauniv.ac.in

    MISSION OF SCS

    To produce world-class professionals who have excellent analytical

    skills, communication skills, team building spirit and ability to work incross cultural environment.

    To produce international quality IT professionals, who can

    independently design, develop and implement computer applications.

    Professionals who dedicate themselves to mankind.

    SCHOOL OF COMPUTER SCIENCE & IT

    DEVI AHILYA VISWAVIDYALAYA

    Takshashila Campus, Khandwa Road, Indore452017

    Tel. (0731)2470027, 2461548 Fax : (0731) 2763618Email:[email protected]

    http://www.scs.dauniv.ac.in/http://www.scs.dauniv.ac.in/mailto:[email protected]:[email protected]:[email protected]:[email protected]://www.scs.dauniv.ac.in/
  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    2/6

    CS-4205 Programming and Problem Solving Using C

    AIM:To enable students in developing programming skills using C language. To improve their

    logical ability and to apply these skills for solving problems in scientific, mathematical andbusiness applications.

    OBJECTIVES:The objectives of the course are :

    To get students understand and solve logical and mathematical problems throughalgorithms and flowcharts.

    To know programming methodologies using C language.

    To design and develop solutions to intermediate level problems using the C language.

    Further develop their skills in software development using a procedural language (theC language).

    Experiments list

    WEEK PRACTICAL LIST

    Week 1

    1.Write a C program to display "Hello Computer" on the screen.

    2.Write a C program to display Your Name, Address and City in different lines.

    3.Write a C program to find the area of a circle using the formula: Area = PI * r2

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

    5. Write a C program to print the multiply value of two accepted numbers

    Week 26.

    Write a C program to convert centigrade into Fahrenheit. Formula: C= (F-32)/1.8.

    7. WWrite a C program to read in a three digit number produce following output

    (assuming that the input is 347)

    3 hundreds

    4 tens7 units

    8. Write a C program to read in two integers and display one as a percentage of

    the other. Typically your output should look like

    20 is 50.00% of 40assuming that the input numbers where 20 and 40. Display the percentage

    correct to 2 decimal places.9. Write a C program to find out whether the character presses through thekeyboard is a digit or not (using conditional operator).

    10.Write a C program to swap variable values of i and j.

    Week 3-4

    11.Write a C program to find the maximum from given three nos.

    12.Write a C program to find that the accepted no is Negative, Positive or Zero.

    13.Write a program which reads two integer values. If the first is lesser print the

  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    3/6

    message up. If the second is lesser, print the message down if they are equal,

    print the message equal if there is an error reading the data, print a messagecontaining the word Error.

    14.Write a C program that prints the given three integers in ascending order using

    ifelse.

    15.

    Given as input three integers representing a date as day, month, year, print thenumber day, month and year for the next day's date.

    Typical input: 28 2 1992 Typical output: Date following 28:02:1992 is

    29:02:1992.

    Week 5

    16.Write a C program for calculator designing using switch /case loop?

    17.Write a C program to convert decimal to binary.

    18.Write a C program to convert decimal to octal.

    19.Write a C program to convert decimal to hexadecimal.

    20.Write a C program to find the sum of first 100 natural nos.

    21.Produce a multiplication table. Top left hand corner will show 1x1 and bottom

    right shows 12x12, as below.

    1 2 3 4 5 6 7 8 9 10 11 122 4 6 8 10 12 14 16 18 20 22 243 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 606 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 10810 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

    Week 6

    22.Write a C program to find the sum of first 100 odd nos. and even nos.

    23.Write a C program to display first 25 Fibonacci nos.

    24.Write a C program to display first 100 prime nos.

    25.Write a C program to find factorial of accepted nos.

    26.Write a C program to find the sum of digits of accepted no.

    27.Write a program in C that will scan a number N and then output

    the sum of the powers from 1 to N. thus, if the input is 4, the output should be

    288 bec. 1+4+27+256=288 [1,2,3,4]

    28.Write a program in C that accepts dates written in numerical form and thenoutput them as a complete form.

    Sample input: 2 26 1986Sample output: February 26, 1986.

    LAB TEST-I

    Week 7 29.Write a C program to print the accepted no and its reverse no.

    30.Write a C program to print all the Factors of accepted no.

    31.Write a C program to find HCF of two given numbers.

    32.Write a C program to find LCM of two given numbers.

    33.Write a C program to find all the prime number between two given numbers.

    34.The National Earthquake Information Center has the following criteria to

  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    4/6

    determine the earthquake damages. Here is the given richter scale serve as an

    input data and the characterization as output information.RICHTER NUMBER (N)....CHARACTERIZATION

    N

  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    5/6

    41.Find value of a given Fibonacci term

    42.Swapping the values of two variable

    43.Minimum/maximum value from the given input

    44.Input todays date and Print yesterdays date. You can use the ANSI standard

    functions 'time' and 'ctime'. An example of the O/P from my program is Fri

    Mar 17 18:46:47 1995 LAB TEST-II

    Week 10-

    11

    45. Write User Defined Function and test them in the main program for the

    following standard function

    a. int myatoi(Char *s)b. char *myitoa(int i)

    c. int mystrlen(char *s)

    d. char *mysubstr(char *s, int i, int j)

    e. char *mystrcat(char *s1,char *s2)f. int mystrcmp(char *s1, char *s2)

    g. int mystrchr(char *s, char c, int i)

    h.

    char *mystrrev(char *s)i. int mystrend(char *s, char *t)j. char *myreplace(char *s, char *old, char *new)

    k. int abs(int i)

    l. char *mytoupper(char *)m.char *mytolower(char*)

    n. int isupper(char *s)

    o. int islower(char *s)

    p. int mypower(int a, int b)q. int mymod (int a, int b)

    Week 12 46. Write the following recursive C Function

    a.

    Factorial of a given numberb. Nth Fibonacci number

    c. Reverse of a given Stringd. Reverse of a give Number

    e. Sin(x)

    Week 13 47.Write a c program to create a new data type Date with the help of structure and

    typedef. Also write following user defined function for date manipulation.

    a. To return next Date,b. To return next Month,

    c. To return next Year,

    d. To add few Days in a date

    e.

    To add few Months in a datef.

    To add few Years in a date

    g. To return the date of the week of a given date.

    h. To return Month name from the date.i. To Display the Date in various format as:

    Date Display(Date d1, char *format)Here Date is the newly created data type.

    The format string can hold the following values:DDMMYYYY, MMDDYY,

    MON, DD, YYYY

    48.Write a C program to implement myprintf and myscanf functions using

  • 8/10/2019 CS 4205 Programming&ProblemSolvingUsingC

    6/6

    Concept of variable number of arguments.

    49. (using getch, putch, gets and puts function)

    50.Write a C program that creates an Employee text file? Records Are empid,

    empname, designation, qualification, salary, experience, Research work,

    address, city phone?

    51.

    Write a C program that manipulates the above text file. The program mustimplements the operation to modify a record, delete a record and append new

    records.

    Week 14 52.Write C programs for the following operation to work like DOS Commands:

    a. type abc.txtb. copy source1.txt source2.txt

    c. copy source1.txt source2.txt source3.txt source4.txt

    d. compare source1.txt source2.txt

    e. concat source1.txt source2.txt

    53.Write a C program to open two files containing integers (in sorted order) and

    merge their contents.

    54.

    Write a C program to count the number of vowels, consonants, digits, spaces,other symbols, words and lines in a given text file.

    55.Write C code to check if an integer is a power of 2 or not

    56.Write a C program to count bits set in an integer?

    57.Write a C program to set a particular bit in a given number.

    58.Write a C program to reset a particular bit in a given number.

    LAB TEST-III

    Week 15 Revision and Tutorial

    Resources:B.W. Kernighan, D.M. Ritchie, The C Programming Language, Prentice Hall of India.

    E Balagurusami, Programming in ANSI C, Tata McGraw-Hill.

    Byron S Gottfried, Programming with C, Tata McGraw-Hill.

    Yashwant Kanetkar, Test your C skills,BPB Publication.

    Behrouz A. Forouzan, Richard F. Gilberg, Computer Science: A StructuredProgramming Approach Using C, Second Edition, Thomson Brooks/cole.

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