Anda di halaman 1dari 2

Computer Programming Lab: Assignment 6

TUESDAY
Q1. Every book published by international publishers should carry an International Standard
Book Number (ISBN). It is a 10 character number, consisting of four parts as shown below:
0-07-041183-2
The first part denotes the region, the second represents publisher, the third identifies the book
and the fourth is the check digit. The check digit is computed as follows:
Sum = (1*first digit)+(2*second digit)+.+(9*ninth digit)
Check digit is the remainder when sum is divided by 11. Write a function that receives a given
ISBN number and checks whether it represents a valid ISBN. (Note: Input has to be read as a
string only. You can convert a character digit into its integer value by subtracting the ASCII
value of character 0 from it.)
Q2. Design and code an interactive and modular program that will use functions to enter a matrix
of m by n size, compute column averages and row averages and print them. (Note: Your program
should work for variable dimensions).
Q3. You are given lines y = mx+k, and a parabola y = ax^2 + bx + c. Write a program using
functions to check whether the two curves intersect. If they do, print the coordinates of point of
intersection (s). Prompt the user to input a point (p,q) and check whether the point lies on any or
both of the curves.

WEDNESDAY & FRIDAY


Q1. Write a function that reverses every word of a given string. For ex., if input is This is a string,
then output should be sihT si a gnirts.

Q2. Write a function that receives marks got by a student in n subjects and returns the average
and percentage of these marks. Call this function from main() and print the results in main().
Q3. The bank gives loans under two different conditions for the rate of interest. Type of interest
can be either: 1. Simple interest (yearly) OR 2. Compound interest (yearly). Write a program by
dividing tasks into functions, which, given the values of principal amount, rate of interest and the
number of years, computes the interest that has to be paid by a person.

THURSDAY
Q1. Write a C program that extracts a substring from another string. You need to create a function
substring(char input_string[], int start_pos, int len). The function should display the required
substring extracted from input_string, starting at position start_pos of length len. Eg., for the input
string Working with strings is fun, start_pos=4 and len=4, it should display king as output.
Consider the invalid conditions (eg., where the len and start_pos are out of bounds).

Q2. Write a function that calculates the gross salary of an employee on the following basis:
Basic pay

HRA

DA .

1 - 4000

10%

50%

4001 - 8000

20%

60%

8001 12000

25%

70%

>= 12000

30%

80%

Determine what parameters must be passed into the function and return the calculation back to
the calling program.
Q3. Declare two arrays whose sizes have to be taken as input from the user. Initialize them with
the numbers between 0-99. You may use the following statement to initialize the elements of the
array.
array[i] = rand()% 100;
Write a program using functions to add two arrays. Note that two arrays can be added only if
they have equal number of elements. Hence, before adding the arrays, your program should
perform a check whether the size of two numbers entered by the user are the same or not.

Anda mungkin juga menyukai