7
Lab Manual Programming Methodology (Pr) COT-211

Lab Manual - National Institute of Technology, Kurukshetranitkkr.ac.in/docs/COT-211_Programming_Methodology-1.pdfNOTE: Implement the following using C Language on Linux or windows

  • Upload
    phungtu

  • View
    216

  • Download
    2

Embed Size (px)

Citation preview

Lab Manual

Programming Methodology (Pr)

COT-211

Lab Instructions

Whether an experiment contains one or

several practicals /programs

One

practical / program

Several

practicals / programs

Whether practical has been verified

and signed by the lab teacher?

Students write experiments in practical files and get them signed by the lab teacher

Students make entries in the list of contents of the practical files and get them signed by

the lab teacher

All Students need to perform the practical/program

Lab Teacher forms groups of the students based on

Assign all practicals /programs among all groups

?

Teacher decides whether the completed practicals / programs can be appropriately described

using flow chart, algorithm, query statement, etc.

Teacher issues necessary instructions to the students for writing practicals / programs

accordingly

In case of an experiment containing several practicals, a lab teacher needs to think whether a practical performed by the students in one group needs to be repeated by the other groups in lab on the same day?

OR A practical performed by the students in one group needs to be repeated as assignments to be completed by the students of other groups in their hostels? Here, an assignment includes both executing a program on computer and also writing the same in practical file.

OR A practical performed by the students in one group needs to be repeated as assignments, only writing practicals in their practical files, for the students of other groups in their hostels?

Teacher issues necessary instructions to the students accordingly.

If a student has not completed a practical, he/she is expected to complete it at his/her

own with the help of his/her fellow students in his/her hostel

The student completes the practical file and submits it to the concerned teacher in

his/her office or mail box on next working day

?

1

Lab Manual Programming Methodology (Pr)

COT-211

L T P

- - 2

Practical exam: 40

Sessional: 60

NOTE: Implement the following using C Language on Linux or windows like platform.

Experiment 1

I. Write a program to calculate compound interest. (Take the necessary input from user).

II. Given an integer n such as 1367. Write a C program that reverses the integer as 7631

and also double the value of inverse as 15262.

III. Write a program to check whether a number is Prime or not.

IV. Write a program to calculate the following Sum. Sum= x2/2! + x

4/4!-x

6/6!+x

8/8!-x

10/10!

(Take ‘x’ as input from user).

V. Write a program to develop a simple text based calculator.

VI. Write a program to represent a number in binary form.

VII. Write a program to find smallest number of coins needed for a given amount. Coins are

of 1 paisa, 5 paisa, 10 paisa, 20 paisa, 50 paisa, 1 rupee and 5 rupee. Example for 3.75

rupee amount, number of coins required is 6.

Experiment 2

I. Write a program to check whether a year is leap year or not.

II. Write a program to print the value of f(x) = ax2+ bx + c for a = 1.0, b=2.0 and c = 1.0 for

x = 3.0, and 4.0 respectively.

III. Compute Julian Day (Julian day is the number of days inclusive for a day counting from

new year day inclusive. January 20 is Julian day 20, April 15 is Julian day 31 + 28 + 31

+ 15 = 105 for an ordinary year and April 15 is Julian day 31 + 29 + 31 + 15 = 106 for

a leap year).

2

IV. Write a program to find the roots of a quadratic equation. (Real and Imaginary, Take the

values of a, b and c from user).

V. Write a program to compute the value of nCm using Recursion where n and m are input

by user.

VI. Write a program to print pascal triangle. Example pascal triangle of order 3 is –

1

1 2 1

1 3 3 1

VII. Read an integer number of a fixed length and then print its digits separated by spaces.

For example if 364 is the input then the output should be 3 6 4.

Experiment 3

I. Write a program to check whether a number is odd or even.

II. Write a program for base conversion (a decimal to another base like binary, octal).

III. Write a program to print diamond pattern. (Use ‘*’ to print the pattern).

IV. Write a program to Generate the first ‘n’ terms of the Fibonacci series. The first and

second terms in the sequence are 0 and 1.

V. Write a program to read three values from keyboard and print out largest of them

without using if statement.

VI. Write a program to check whether a number is Armstrong or not (e.g. 153=13+5

3+3

3).

VII. Write a program to solve Towers of Hanoi problem.

Experiment 4

I. Write a program to find the sum of individuals digits of a positive Integer.

II. Write a program to find first and second largest of input number in order of O(n) time

complexity.

III. Write a program to reverse a string.

3

IV. Write a program to find the 2’s compliment of a binary number.

V. Write a program to delete n characters from a given position in a given string.

VI. Write a program that displays the position or index in the string S where the string T

begins or -1 if S doesn’t contain T.

VII. Write a program to compare two strings without using any string function.

Experiment 5

I. Write a program to find the GCD (greatest common divisor) of two given integers in

recursive and non recursive way.

II. Write a program to check whether input alphabet is vowel or not.

III. Write a program for magic square.

IV. Write a program, which takes two integers operands and one operator from the user,

performs the operation and prints the result.(Consider the operators +,-,*,/,% and use

switch Statement).

V. Write a program to delete the duplicate element of an array in order of O(n) time

complexity.

VI. Write a program to count the words and characters in a given sentence.

VII. Implement a GUI/Mouse driven simple calculator.

Experiment 6 (File Handling)

I. Write a program to Create a File & Store Information.

II. Write a program to illustrate Reading of Data from a File and to delete or replace a

specific Line from a Text File.

III. Write a program that Merges Lines Alternatively from 2 Files & Print Result.

IV. Write a program to Create Employee Record and Update it .

4

V. Write a program to Convert the Contents of File to Lower case and replace First

Letter of every Word with Capital Letter .

VI. Write a program to Count No of Lines, Blank Lines, Comments in a given Program

and also Reverse the Contents of a File and Print it .

VII. Write a program to Create Employee File Name Record that is taken from the

Command-Line Argument .

Experiment 7 (Hashing)

I. Write a program to implement Division-Remainder hashing.

II. Write a program to implement Mid-Square hashing.

III. Write a program to implement Folding hashing.

IV. Write a program to implement Division-Remainder hashing.

V. Write a program to calculate load factor.

VI. Write a program to calculate Linear probing.

VII. Write a program to calculate double hashing.

VIII. Write a program to calculate synonym chaining.

Experiment 8 (B-tree and Merging)

I. Write a program that builds a B-tree of order 3 from an input sequence of key values.

II. Write a program to traverse a B-tree of order 3 in sequence by key value.

III. Write a program to locate a given key value in a B-tree of order 3.

IV. Write a program to maintain a B-tree of order 3. Be able to accommodate key

insertions and deletions.

V. Write a program to implement Natural merge.

VI. Write a program to implement Balanced merge.

VII. Write a program to implement Cascade merge.