Sie sind auf Seite 1von 10

CONFIDENTIAL

Threaded Assignments for Programming & Testing












CONFIDENTIAL
COPYRIGHT NOTICE

All ideas and information contained in this document are the intellectual property of
Education and Research Department, Infosys Limited. This document is not for
general distribution and is meant for use only for the person they are specifically
issued to. This document shall not be loaned to anyone, within or outside Infosys,
including its customers. Copying or unauthorized distribution of this document, in
any form or means including electronic, mechanical, photocopying or otherwise is
illegal.

Education and Research Department
Infosys Limited
Electronics City
Hosur Road
Bangalore - 561 229, India.

Tel: 91 80 852 0261-270
Fax: 91 80 852 0362
www.infy.com
mailto:E&R@infy.com
Infosys Limited Table of Contents

ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 iii
Contents

CONTENTS................................................................................................................. III
CONTEXT ...................................................................................................................1
GUIDELINES ................................................................................................................1
COURSE MANAGEMENT SYSTEM- PROBLEM SPECIFICATION......................................................1
DAY-1 EXERCISES .........................................................................................................1
EXERCISE 1: PSEUDO CODE- SELECTIONAL PATTERN ........................................................................ 1
EXERCISE 2: TEST A SELECTIONAL PATTERN PSEUDO CODE(1) ............................................................. 2
EXERCISE 3: TEST AN ITERATIONAL PATTERN PSEUDO CODE ................................................................ 3
DAY-2,3 AND 4 EXERCISES(TO BE COMPLETED BY END OF 4
TH
DAY) ..........................................4
EXERCISE 4: IDENTIFY DATATYPES AND DECLARE VARIABLES................................................................ 4
DAY-5 EXERCISES .........................................................................................................5
EXERCISE 5: USING A TWO DIMENSIONAL ARRAY ............................................................................ 5
DAY-6 EXERCISES .........................................................................................................6
EXERCISE 6: STRINGS AND THEIR MANIPULATION............................................................................ 6
EXERCISE 7: STRINGS AND THEIR MANIPULATION............................................................................ 6

Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 1 of 7
Context
This document contains Exercises to be completed as part of the practice session for the
subject Programming Basics.

Guidelines
The threaded Exercise contains the step wise and incremental creation of the Course
Management system. It has been designed to give hands on and domain experience to
map the concepts learnt in the theory session to practice and solve a larger problem
The Exercises are organized day-wise based on concepts learnt
These Exercises have to be submitted everyday as per the schedule along with the lab
guide Assignments

Course Management System- Problem Specification

A Course Management System needs to be developed for an engineering college. The college
wants an automated system to replace its manual system for purpose of allocation of students
to courses and lecturers to courses. The engineering college provides education in the
various branches of engineering. In any branch, the entire graduation is divided into
semesters. Each semester includes various courses. Students admitted into the college can
apply for various courses. The courses are elective in nature. The student needs to select
two electives. The electives are offered from 5th semester onwards.
The system is used by the admin staff to register students admitted to college to the courses
opted. The system needs to be authenticated with a login id and password.
The complete list of courses and students is maintained in the college. The list is constant
and cannot be updated by the system. The automated system uses this list for allocation of
courses.
Day-1 Exercises
Note: The pseudo code can be written in notepad and saved as .txt files and submitted. For
the trace tables, excel sheets or tables embedded in word documents can be submitted.
Exercise 1: Pseudo code- Selectional pattern

Objective: To Write pseudo code for selectional pattern problems

Background: Selectional patterns are used for making decisions. They are useful while
validating data. Validation is needed to check the correctness of the data being entered
which if not done, leads to incorrect results

Problem Description: A student of a College wants to register for elective courses offered by
the college.
The student should be able to enter the following details:
Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 2 of 7
Number of Courses for which he/she wants to register. A student is allowed to register
for a minimum of one course and a maximum of 2 courses. In case the Number of
Courses entered is more than 2, an appropriate error message should be generated.

The Course Id of the two courses. Course Ids should be greater than or equal to 5001
and less than or equal to 5005. If not, an appropriate error message should be
generated.

If all the data entered by the student are valid, the following success message should
be displayed You have successfully registered for the courses.

Estimated time: 30 minutes

Step 1: Analyze the problem.

Step 2: Identify the data to be accepted

Step 3: Identify the validations to be done

Step 4: Identify the computation/calculation statements

Step 5: Write the Pseudo code


Summary of this Exercise:
In this Exercise, you have learnt:
To analyze a selectional problem and write the pseudo code using selectional
statements for a specific problem, ie. The Course Management System
Exercise 2: Test a Selectional pattern Pseudo code(1)

Objective: Test a pseudo code using dry run technique and trace table

Background: Pseudo code can be tested without computers by dry running

Problem Description: Dry Run the pseudo code written for Exercise 1 using Trace Table

Estimated time: 30 minutes

Case 1: Dry run the pseudo code using Trace table when the inputs are as given below:
Number of Courses = 1, Course Id = 5001

Case 2: Dry run the pseudo code using Trace table when the inputs are as given below:
Number of Courses = 2, Course Ids are 5001 & 5004

Case 3: Dry run the pseudo code using Trace table when the inputs are as given below:
Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 3 of 7
Number of Courses = 3, Course Ids are 5001, 5003, 5005

Case 4: Dry run the pseudo code using Trace table when the inputs are as given below:
Number of Courses = 1, Course Ids are 5000

Case 5: Dry run the pseudo code using Trace table when the inputs are as given below:
Number of Courses = 1, Course Ids are 5006

Case 6: Dry run the pseudo code using Trace table when the inputs are as given below:
Number of Courses = 2, Course Ids are 5002, 5007

Summary of this Exercise:
In this Exercise, you have learnt:
To dry run a selectional pattern pseudo code to test all the logical paths being covered
Objective: Write pseudo code for iterational pattern problems using for loop

Background:
Iterational pattern is used to repeat a certain activity for a certain number of times. An
iteration has a counter, a stop condition for the iteration and an activity to be done

Problem Description: The problem given in Exercise 5 should be extended in such a way that
5 students can now register for courses. In case of an error, the system should reenter the
data until a valid input is obtained.

Estimated time: 25minutes

Step 1: Analyze the problem.

Step 2: Identify the activities to be iterated

Step 3: Identify the counter initial value, termination condition for the iterational construct

Step 4: Write the Pseudo code

Summary of this Exercise:
In this Exercise, you have learnt:
To analyze an iterational problem and write the pseudo code using iterational
statement (for loop)
Exercise 3: Test an Iterational pattern Pseudo code

Objective: Test a pseudo code using dry run technique and trace table

Background: Pseudo code can be tested without computers by dry running

Problem Description: Dry Run the pseudo code written for Exercise 2 using Trace Table
Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 4 of 7

Estimated time: 30 minutes

Case 1: Dry run the pseudo code using Trace table when the inputs are as given below:

Student No No of Courses Course Id for 1
st
course Course Id for 2
nd
course
1 1
st
iteration: 1 1
st
iteration: 5001
2 1
st
iteration: 3 1
st
iteration: 5000 1
st
iteration: 5003

2
nd
iteration: 2 2
nd
iteration: 5002

3 1
st
iteration: 0 1
st
iteration: 5005

2
nd
iteration: 1
4 1
st
iteration: 2 1
st
iteration: 5004 1
st
iteration: 5006
2
nd
iteration: 5003
5 1
st
iteration: 2 1
st
iteration: 5007 1
st
iteration: 5000

2
nd
iteration: 5003 2
nd
iteration: 5005


Summary of this Exercise:
In this Exercise, you have learnt:
To dry run a iterational pattern pseudo code so that all the logical paths are covered

Day-2,3 and 4 Exercises(To be completed by end of 4
th
day)

Exercise 4: Identify Datatypes and declare variables

Objective: To identify the appropriate data type, declare the variables and perform
validations

Background: Accepting data and validating them is a very crucial requirement

Problem Description: Create a file called student.c. Write the code in the student.c file .
Declare variables for the following and perform the validations for the process of allocation of
course to a student as given below:

Accept Student ID. It should be between 1001 and 1005.Otherwise, display an error
message and quit the program.
Accept the semester to which the student belongs. It should be the 5
th
semester.
Otherwise, display an appropriate error message and exit the program
Initialize a variable for storing the number of courses opted by the student and
initialize to 0.
Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 5 of 7
Check if the number of courses opted by the student is zero.If not, display an error
message and quit the program.
Accept the Course ID. It should be between 5001-5005. Otherwise, display an
appropriate error message and exit the program.
Display a message in the following format:
Ex:Course ID 5002 is allocated to student with ID 1003
Increase the number of course opted by one

Repeat the process of allocation of course Id two times as two courses need to be
allocated to the student.

Estimated time: 30 minutes

Summary of this Exercise:
In this Exercise, you have learnt:
To declare variables and validate the data using control flow structures
Day-5 Exercises

Exercise 5: Using a two dimensional array

Objective: Use a two dimensional array for storing and manipulating related data

Background: A two dimensional array represents a good data structure to hold related data

Problem Description: Reuse the code written in file student.c. Make necessary
modifications for the following:

Declare a two dimensional student array of order 2 x 5 and initialize it to zero. This
array would store the student ID in the first row and the number of courses opted in
the second row.
Declare a two dimensional course array of order 2 x 5 to store the Course ID 1 in the
first row, Course ID 2 in the second row. Initialize this array to zero values.
Declare a string to store the student name .(one dimensional array only)
Accept Student ID. It should be between 1001 and 1005.Otherwise, display an error
message and quit the program.(Use code written in Exercise 4)
Accept the semester to which the student belongs. It should be the 5
th
semester.
Otherwise, display an appropriate error message and exit the program. (Use code
written in Exercise 4)
Check if this student ID is already present in the student array. If yes, display an error
message that the student already exists and exit the program.
Accept the student name.
Accept the first Course ID. It should be between 5001-5005. Otherwise, display an
appropriate error message and exit the program.
Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 6 of 7
Store the first course ID in the appropriate position in the course array.
Accept the second Course ID. It should also be between 5001-5005. If not, display an
appropriate error message.Check if this course ID has already been accepted for the
accepted student ID.If yes, display an appropriate error message. (The student should
not opt for the same course two times).
Store the second course ID in the appropriate position in the course array.
Increase the number of courses opted by the student to 2 in the student array for the
accepted student ID.
Repeat this process to allocate the courses to 5 students.

Estimated time: 40 minutes

Summary of this Exercise:
In this Exercise, you have learnt:
To use a data structure to store the data and manipulate the same.
To search for a data in the data structure using linear search
Day-6 Exercises

Exercise 6: Strings and their manipulation

Objective: Usage of strings

Background: Strings are used very commonly in real life. C language has specific features for
handling strings.

Problem Description: Use the student.c file created in Exercise 6. Make the following
additions to the already written code.
Declare a two dimensional array of strings 5x26 and store the following courses
C,CPP,Java,Oracle,DotNet.
Declare a two dimensional array of strings 5x26. Store the name accepted for each
student (in exercise 6) in the appropriate position in this two dimensional array of
strings.
Estimated time: 15 minutes

Exercise 7: Strings and their manipulation

Objective: Usage of string handling functions

Background: Strings are used very commonly in real life. C language has specific features for
handling strings.

Problem Description: Create a file login.c . Write the code in this file.

Infosys Limited Threaded Exercise for Programming & Testing
ER/CORP/CRS/SE1035/007 CONFIDENTIAL Version No. 1.1 7 of 7
Accept a user name. The maximum length for the user name can be 10 characters. If
not, display an error message and exit the application.
Accept a password. The password should not be displayed on the screen. The password
can be of maximum 10 characters in length. If not, display an appropriate error
message and exit the application.
The user name can be one of the following: User-1, User-2, User-3. If not, display an
appropriate error message and provide three attempts for re-entry of the user name
and then quit the program. Note that the comparison is case insensitive.
The password can be Infosys only. A case sensitive comparison is made. If the input is
invalid display an appropriate error message and allow three attempts for reentry of
the password and then quit the program.
Display a success message if the login is successful ie. if the both the user name and
password are correct.

Estimated time: 25 minutes

Summary of this Exercise:
In this Exercise, you have learnt:
To use string handling functions

At the end of these exercises
You have completed the course allocation to students and the code is available in
student.c
You have completed the login module for authentication and the code is available in
login.c

The way forward-

These files would be used in the Structured Programming to include modular programming
and to integrate the two modules into one application.

Das könnte Ihnen auch gefallen