Você está na página 1de 16

CSE 112PROBLEM SOLVING USING

COMPUTERS LAB

II Semester, BTECH
[common to all Branches]

(January 2013)

LA B M A N U A L

DEPT OF COMPUTER SCIENCE & ENGINEERING


M. I. T., MANIPAL
2013

I N S T R U C T I O N S

T O

S T U D E N T S

1. Students should be regular and come prepared for the lab practice.
2. In case a student misses a class, it is his/her responsibility to complete that missed
experiment(s).
3. Students should bring and maintain an observation book exclusively for the lab.
4. Once the experiment(s) get executed, they should show the program and results to the
instructors and copy the same in their observation book.
5. Students are also required to draw the corresponding flowcharts in the observation book
during the lab hours itself which will be evaluated.
Flowcharts need not be drawn for the programs from week 7(Arrays).
Prescribed textbook and class notes can be kept ready for reference if required.
6. They should implement the given experiment individually.
7. While conducting the experiments students should see that their programs would meet the
following criteria:
Programs should be interactive with appropriate prompt messages, error messages if any,
and descriptive messages for outputs.

Programs should perform input validation (Data type, range error, etc.) and give
appropriate error messages and suggest corrective actions.

Comments should be used to give the statement of the problem and every function should
indicate the purpose of the function, inputs and outputs

Statements within the program should be properly indented.

Use meaningful names for variables and functions.

Make use of Constants and type definitions wherever needed.

8. Copying programs/lab work blindly from other students or yesteryears is strictly prohibited
and will fetch penalty for lab evaluation.
9. Questions for lab tests and exam need not necessarily be limited to the questions in the
manual, but could involve some variations and / or combinations of the questions.
* Above-mentioned instructions can be modified based on the context of the lab.

Department of Computer Science & Engineering

2|Page

MO D E O F E V A L U A T I O N

Department of Computer Science & Engineering

3|Page

C O N T E N T S
WEEK NO

TITLE OF EXPERIMENT

1.

WORKING WITH DOS COMMANDS

2.

MS-WORD (BASICS)

3.

MS-EXCEL & POWERPOINT (BASICS)

4.

RAPTOR- A PROBLEM SOLVING TOOL TO GENERATE


FLOWCHARTS

5.

TCPLUS EDITOR AND SIMPLE PROGRAMS

6.

DECISION MAKING & BRANCHING CONTROL


STRUCTURES

7.

LOOPING CONTROL STRUCTURES

8.

1-D ARRAYS

9.

2-D ARRAYS

10.

STRINGS

11.

FUNCTIONS

12.

TEST FOR FIRST BATCH

13.

TEST FOR SECOND BATCH

14.

STRUCTURES, POINTERS AND FILE HANDLING

REFERENCES / TUTORIALS
ADDITIONAL EXERCISES
Department of Computer Science & Engineering

4|Page

Lab 1: WORKING WITH DOS COMMANDS


Introduction to DOS, Familiarization with DOS Commands. (DIR, MD, CD, RD,
COPYCON, TYPE, EDIT, DEL, COPY, MOVE, REN, TREE, CLS)

Understanding the DOS Editor.

Lab 2: MS-WORD (Basics)


Bio-Data
 Type your bio-data using MS-Word as per the format specifications (as shown below and fill
all the fields)
BIO DATA

1. NAME:

Insert a
picture from
clipart

2. FATHERS NAME:

3. DOB:

4. REG NO:

5. PERMANENT ADDR:

6. ACADEMIC PERFORMANCE:

Slno
1.
2.
F O R M A T






Name of school/college
St Anthonys
..

Class
10th
.

Percentage
78%
.

S P E C I F I C A T I O N S

Select Page Margins


Left Margin 1 inch, Right Margin 1 inch Top and bottom Margins 1.2 inch each
Font Size
For Heading 18, Remaining text14
Paper size
8.5 width*11 Height in inches, Portrait
Draw Border Line

Department of Computer Science & Engineering

5|Page

Mail Merge
 You wish to send information about a new web-authorizing tool developed by your company
to the prospective clients. Create a new document of about 6 to 10 line describing the
product. Create a data of source file with fields as first name, last name, company and city.
Enter the data for 4 5 clients. Merge the main document with this data file to create a new
document. View the new document.

Paragraph Formatting
 Following is an exercise in formatting paragraphs. Before you start you may need to change
the ruler from inches to centimeters. You can do this by selecting Options from the Tools
menu and then selecting the general tab. Then select centimeters from the measurement
units drop down list. (Remember to use Edit / Undo if you make a mistake.) Consider a
paragraph given below.
Before starting, check that you are viewing this in Microsoft Word. If you left clicked on
the link in your web browser to come here, you will be viewing this through Internet
Explorer. You can check this by clicking on the Help menu and seeing if it lists either
About Microsoft Word or About Internet Explorer.

If it says, About Internet

Explorer you have opened this fine in the incorrect way, and so you can use the Back
button on the browser to go back and download the document in the correct way. If it
says About Microsoft Word, youve done it correctly carry on.
Format the above paragraph in the following ways:
a) The left and right margins are to be brought in by 1 cm from the page margins.
(Hint: First of all Click somewhere in this paragraph to make sure you are in the
correct paragraph. The easiest way to do this is to move the lower triangular shape
on the left hand side of the ruler in to 1cm and the triangle on the right into 13.6cm.
)
b) Set a hanging indent
(Hint: This can be done by moving the upper left triangle

on the ruler.)

c) Now justify the paragraph so that it has nice smooth edges.

Letter Writing
 Write a letter to your friends (more than one) containing information regarding your home
town. The letter should include the followings




A table containing information such as area, population, distance from capital city etc.
Photos of historical places in your home town (Refer sample pictures available on your
computer) and
Relevant details (lines of text) about the place with necessary font and format.
Department of Computer Science & Engineering

6|Page

Format the following lines as it is instructed in the respective line




Format this line as Bold, Italic, Arial font face, dark blue color and 15pt font size.

Change the word 2nd so that it looks like 2nd.

Change the word H2O so that it looks like H2O.

Format this sentence so that the words, and not the spaces between the words, are
underlined.

Change all of the text in this line to title case.

Format this sentence to reduce the amount of space between each letter by 1 point.

Format the following line so that it is Bold, font size 28 with Kerning turned on.

Lab 3: MS-EXCEL & POWER POINT (Basics)


M S - E X C E L
 Problem-1


Create a datasheet containing the data about students: roll no, name, subject wise marks

Calculate the total marks & Average of each student. Use functions.

Draw the bar chart for the above table, make changes to the cell values & observe the
changes in the chart.

 Using hyperlink, link this sheet with the word files.

 Problem-2
Create a table containing the following information.
Itemcode, Qty, Price, Sales, Commission and remarks


Commission = 0.1 % of Qty.

Sales = Qty *Price.

Enter 5 suitable records into the above table then compute the following.


Total Sales

Highest Sales

Lowest Sales

Average Sales

Show item wise sales display using bar chart, Line graph, Pie Chart.

Department of Computer Science & Engineering

7|Page

M S - P O W E R P O I N T
 Problem-1


You are the leader of a software development team & your team wants to develop a new
software product. You are required to make a presentation about this product to the
management. Develop a power point presentation consisting of the following slides

Slide 1: 3- 4 lines of text describing the salient features of the product.


(Examiners can ask you to change the design, font, and color scheme for this slide)
Slide 2: A summary (4-5) lines of the prospects for the new product. Create the summary using
MS-Word and embed it into this slide. Demonstrate the concepts of embedding by showing that
even if the original word document is changed this slide remains unaltered.
Slide 3: Organization chart for the development team. The chart format using the
Organization chart utility is as shown below:

Development team

In each box, fill suitable names titles & comments (examiners can ask you to change the style,
levels, box properties & text inside the boxes for this chart)
Slide 4: A pie chart showing the breakup of the project development cost.
Use Excel for entering suitable values & for creating the pie chart. Link this chart to slide 4.
Demonstrate the concept of object linking by showing that when the data in the Excel
spreadsheet is changed: the contents of this slide also change automatically.
Run the slide show with the 4 slides created in the preceding steps
(Examiners/Instructors can ask to change the slide transition effect, standard transition sound
effect and design for all the slides)

 Problem-2
Use Power point presentation to demonstrate the work you have done till now in this session. (At
least 4 slides)

Department of Computer Science & Engineering

8|Page

Lab 4: RAPTOR
Draw flowcharts for each of the following algorithm using RAPTOR tool

Perform the four basic arithmetic Operations [e.g. sum=a+b; diff=a-b; prod=a*b;
quot=a/b]

Evaluate the area of the circle Area = Pi * R 2

Convert the time in seconds to hours, minutes and seconds. (1 hr =3600 sec).

Find the sum of the digits of a 3-digit number [ex 123 sum=6](no looping).

Convert temperature given in Fahrenheit to Centigrade and Centigrade to Fahrenheit.


(C=5/9(F-32)).

Convert distance in mm to cm, inch, feet (1 cm =10mm, 1inch=2.5cm, 1 feet =12


inches).

Lab 5: TCPLUS EDITOR & SIMPLE PROGRAMS


 Turbo C Plus editor

Menu Bar

Key Short cuts (F1, F2, ALT-F9, CTRL-F9, ALT-F5)

Context Help (CTRL-F1)

Tracing an Program Execution- (CTRL-F7, F7, F8, F4)

 Simple Programs

Program to input P, N and R and perform simple interest calculation. (SI=PNR/100)

Program to find the volume and surface area of sphere (given in radius)
(Hint: volume=(4r3)/3, Area=4r2).

Program to perform the four basic arithmetic Operations [e.g. sum=a+b; diff=a-b;
prod=a*b; quot=a/b]

Program to evaluate the surface area of the cylinder. (A=2 pi r 2 + 2 pi r h )

Convert the time in seconds to hours, minutes and seconds. (1 hr =3600 sec).

Find the sum of the digits of a four-digit number (ex 1234 sum=10).

Convert temperature given in Fahrenheit to Centigrade and Centigrade to Fahrenheit.


( int: (C=5/9(F-32)) ).

Department of Computer Science & Engineering

9|Page

Lab 6: DECISION MAKING AND BRANCHING


CONTROL STRUCTURES

Check whether the given number is odd or even.

Write a C++ program to find square and cube value of a 2 digit odd number

Write a C++ program to show the greatest number between three numbers using IF-ELSEIF statement.
Write a C++ program to illustrate bitwise OR, AND and X-OR operations on 2
binary numbers.
Write a C++ program to illustrate LEFT and RIGHT shift operations on a binary
number.
Write a C++ program to illustrate LOGICAL and RELATIONAL expressions on 2
binary numbers.

Find the roots of a quadratic equation (use of Switch and Break).


Hint : root = -b +/- sqrt(b2-4ac)/2a

Write a C++ program to check whether given number is zero, positive or negative using
IF-ELSEIF-ELSE statement

Lab 7: LOOPING CONTROL STRUCTURES

Generate the multiplication table for n numbers up to k terms ( nested loops).


o Hint :

1 2 3

4 5 . K

2 4 6

8 10 ..2*k

..

n .. nK
Evaluate the sin series sin x= x - x3 /3! + x5 /5! x7 /7! + to n terms.

Generate prime numbers between a given limit.

Write a program that examines all the numbers from 1 to N, displaying all those for
which the sum of the cubes of all the digits equals the number itself.

Reverse a given number.


o Ex: 1234 reverse=4*10 3 +3 * 10 2 + 2 * 10 1 + 1 * 10 0 =4321

Department of Computer Science & Engineering

10 | P a g e

Lab 8: 1-D ARRAYS

Find the largest and smallest element in an array.

Write a C++ program to find the array C such that C[i]=A[i]+B[i]

Insert an element into an array and Delete an element from an array

Print all the prime numbers in an given array

Arrange the elements of an array in ascending order by simple sorting method. (Selection
sort / bubble sort)
Insert an element into a sorted array (new array should be sorted one).

Two sets are represented by arrays A and B. Find AUB, A^B and A-B.

Lab 9: 2-D ARRAYS


Add, subtract and multiply two matrices.

Compute the row sum and column sum of a given matrix.

Check if the given matrix is magic square or not.

Find whether a given matrix is symmetric or not.


o Hint: A = AT

Find the trace and norm of a given square matrix.


o Hint: Trace = sum of principal diagonal elements
o Norm = SQRT (sum of squares of the individual elements of an array)

Searching for an element in the matrix and counting the number of its occurrences.

Lab 10: STRINGS


Write programs without using STRING-HANDLING functions.

Count the number of words in a sentence.

Write a C++ program which toggles the case of every character in the input string
(Eg: INPUT: aBcDe OUTPUT:AbCdE)
Write a C++ program to mask password with *.

Find the sub string of a given string.

Write a C++ program which deletes a word from the given sentence. (Eg: INPUT: I AM
STUDYING IN MIT, TO BE DELETED: STUDYING, OUTPUT: I AM IN MIT)

Check if the given string is a palindrome or not.


Department of Computer Science & Engineering

11 | P a g e

Lab 11: USER DEFINED FUNCTIONS

Find the factorial of a number using function.


o (Ex: 5! =5*4*3*2*1. Use a function Fact to evaluate factorial & print the result).

Find the maximum of a given set of numbers using functions.


o (Use a function Max and return the result to main function)

Find GCD of two numbers recursively. (Ex: GCD of 9,24 is 3)

Write a function to check whether the given number is prime or not. Generate first n
prime numbers using the above function.

Write a function to generate nth Fibonacci term using recursion. Print first N Fibonacci
terms using this function.
Hint: (fibonacci series is 0, 1, 1, 2, 3, 5, 8,)

Check if the given string is a palindrome or not, using string handling function.

Write a function Sort for sorting a list of names which will use a function compare to
compare two names. (Selection /bubble Sort may be used).

Lab 12: TEST FOR BATCH-I


Lab 13: TEST FOR BATCH-II
[Date and batch for End Semester lab exam will be announced]

Lab 14: STRUCTURES, POINTERS and FILE


HANDLING
S TRUCT URE S

Define a structure type, personal that would contain person name, date of joining and
salary.

Using this structure write a program to read this information for one person

from the keyboard and print the same on the screen.

Create an array of student structure to store the roll no., name and marks in 3 subjects.
Input the details of N students in to the array and display roll no., name, and total marks
of each student in decreasing order of total marks.

P OINTERS

Access two integers using pointers and add them.

Compute the sum of all elements stored in an array using a pointer to an array.

Determine the length of a character string using a pointer to string.


Department of Computer Science & Engineering

12 | P a g e

FILES

Write a program to read a sentence from a file and display the same on the screen

Write a program to write a line of text into an existing file.

Write a program to copy the contents of one file into another file.

Department of Computer Science & Engineering

13 | P a g e

REFERENCES / TUTORIALS
 Programming in ANSI C E. Balaguruswamy
 Object Oriented Programming in C++ - E. Balaguruswamy
 Herbert Schildt, C++: The Complete Reference 4th edition - Tata McGraw-Hill.
 Robert LaFore, Galgotia Object Oriented Programming with Turbo C++ - Publications,
2002
. P r o g r a m m i n g i n C , P r a d i p D e y a n d M a n a s G h o s h , S e c o n d E d i t i o n ,
Oxford University Press, 2011

ADDITIONAL EXERCISES
1) Write a program to find the determinant of a square matrix.
2) Write a program to check whether a saddle point exists in a given matrix.(i.e element
which is minimum in row and maximum in column)
3) Write a program, which generates all the possible combinations of a 3-digit number.
4) Given a list of N numbers in the range 1 to N (not necessarily in the order) and out of that
one number is missing (i.e. only N-1 inputs), write a program to find the missing number.
5) Write a program to find the time of the day when
a) Hour and Minute hand are exactly opposite to each other.
b) Hour and Minute hand are overlapping each other.
6) Given 4 numbers 1,2,3 and 4. Find all possible 4-digit numbers that can be formed using
these 4-digits. From these numbers, generate the permutation of the 4 digits (i.e. 4 digits
are distinct)
7) Write a program to find the median of N numbers.
8) Write a program to check whether the given number is Armstrong Number.
9) Create an array of employee structure to store emp-no, name, basic salary and hra. Input
the details of N employees and display emp-no, name, basic, hra and net salary. Display
the details of all employees whose net salary is more than the average net salary of all
employees.
10) Input N numbers and place only those numbers whose Pth position (specified by user) is
divisible by 3 into an array. (Eg: The numbers input : 1223, 1243, 1232; position P=4
(left to right) then the resultant array will {1223,1243})
11) A number has all its digits squared and added together to make a new number. This
process is repeated until a 1 is obtained, then the original number is described as
Department of Computer Science & Engineering

14 | P a g e

HAPPY. If a 1 is never obtained, then the original number is said to be SAD. { eg.:
19 = 12+92= 82=> 82+22 =68=>62+82 =100=>12=1}
12) Write a program to delete blanks from a given string.
13) Write a program to display following output for N number of lines.

1
14) Find the inverse of a matrix A.
15) Find the solution to the system of simultaneous equations using Guass- Jordan
elimination method.
16) Display the list of perfect squares in the given mXn matrix.
17) Given a string S1=This is a way to do this and a string S2=is find the positions of
occurrence of S2 in S1.
18) Replace odd numbers in a matrix by zeroes.
19) Display all the Pythagorean triplets up to n. (Eg: 32+42 = 52 ).
20) Write a program to find the transpose of a matrix without using another matrix.
21) WAP to print the abbreviation of a given name. (Eg: Central Computing Facility =>
C.C.F)
22) WAP to simulate an arithmetic calculator.
23) Replace each element of the matrix by its factorial.
24) Find the odd numbers in a given matrix and display its row and column number.
25) Convert 3X3 matrix to a 4X4 matrix.
Eg: Original Matrix:
1

18

New Matrix:

Department of Computer Science & Engineering

15 | P a g e

26) WAP to print all combinations of a given word. (Eg: Rose => oser, osre. Etc)
27) Write an n digit number in words.( 236=two three six)
28) Find the volume of a cylinder and a cube.
29) Find the LCM of two numbers.
30) Find all the primes in the multiplication tables ranging from 2 to 5 and store them in array
without having duplicates.
31) Check all the rows, columns, principal diagonal, and secondary diagonal for palindromes
in an integer matrix of any order.
32) WAP to find the digital roots of numbers for multiplication tables ranging from 2 to 5 and
store those forty resultant numbers in a matrix of order 4X10. (Digital root of number is
a single digit derived from adding all the individual digits of the number repeatedly. (Eg:
digital root of 2456= 2+4+5+6=17, again 1+7=8---> digital root)
33) Generate

1
1
1
1

1
2

1
3

1
4

34) Write a program to read a line, encode the line and display the original and encoded form.
The encode should be:
a

c d .. z

x w . a

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Department of Computer Science & Engineering

16 | P a g e

Você também pode gostar