Sie sind auf Seite 1von 8

CS101 BASICS OF PROGRAMMING ( LAB )

List of programs
Week 1:
1. Write a C program to find the greatest and smallest of three numbers.
2. Write a program in C for the Air force to label an aircraft a military or civilian.
The program is to be given the plane's observed speed in km/h & its estimated
length in meters. For plane travelling in excess of 1100km/h & longer than
52m, you should label them as "civilian" aircraft, & shorter such as 500 km/h
& 20m as "military" aircraft. For planes travelling at slower speeds, you will
issue an "It's bird" message.
3. Write a C program for the following problem.
The National Earthquake Information Center has the following criteria to
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<5.0

little or no damage

5.0<=N<5.5

some damage

5.5<=N<6.5

serious damage

6.5<=N<7.5

Disaster

Higher
Catastrophe
4. Write a program in C that accepts dates written in numerical form and then
output them as a complete form.
Sample input:

2 26 1986

Sample output:
February 26, 1986
5. Get the input as name of a person and his age in years. Write a C program to
compute how many seconds that person have lived till this age.
Week 2:
1. Write a C program to convert the Fahrenheit value into Degree Celsius value.
2. Write a C program to solve the roots of a quadratic equation and print all the
possible roots. Use switch statements to handle different values of the
discriminant d = b2 4ac
3. Write a C program to check whether a given integer is Palindrome or Not.

4. Write a C program to check whether a given integer is an Armstrong Number


or Not.
5. Write a C program to find the sum of digits of a given integer until the sum
yields a single digit.
Week 3:
1. Write a C program to print the numbers that are divisible by 7 between 1 and
100. Also find the sum of those numbers and print that sum.
2. Write a C program to generate every third integer from 0 to N (N<100). Also
calculate the sum of those integers that are evenly divisible by 5.
3. Write a C program to print the first N Prime Numbers.
4. Write a C program to print the sum of all squares between 1 and N.
5. Get the input as currency in Indian Rupees. Write a C program to print a
conversion chart of various currencies as shown in the table below.
----------------------------------------------------------------------------------Rs
US $
Dinar
Yen
Pound
----------------------------------------------------------------------------------xx
xxx
xxx
xxx
xxx
----------------------------------------------------------------------------------Week 4:

1.

Write a C program to print the following pyramid of digits.


1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5

2.

Write a C program to print the following patterns.


1

3.

1 2
2 2
2 3
1 2 3
3 3 3
4 5 6
1 2 3 4
4 4 4 4
7 8 9 10
1 2 3 4 5
5 5 5 5 5
11 12 13 14 15
Write a C program to compute the exponential value of a given number X
using the following series.

e(x) = 1 + x + x2 / 2! + x3 / 3! +
4.

Write a C program to compute the Cosine value of a given number X using the
following series.
Cos(x) =

5.

1 - x2 / 2! + x4 / 4! - x6 / 6! +

Write a C program to compute the Sine value of a given number X using the
following series.
Sin(x) =

x - x3 / 3! + x5 / 5! - x7 / 7! +

Week 5:
1. Write a C program to perform the following number conversions.
i. Decimal to Binary
ii. Binary to decimal
iii.
Decimal to Hexadecimal
iv. Hexadecimal to Decimal
2. Write a C program to compute the mean, variance and standard deviation for a
given set of numbers using the following formula.
QuickTime and a
decompressor
are needed to see this picture.

where x1, x2, x3, .xN are the given set of N numbers whose mean value
is and standard deviation is

Week 6:
1. Write a C program to order the elements of an integer array using Bubble Sort
and print it in ascending and descending order.
2. Write a C program to find the sum of odd and even numbers in an integer
array.
3. Write a C program to perform Linear search for a given number X in an

integer array. Also find the frequency and position of occurrences of X.


4. Write a C program to perform addition of two matrices.

Week 7:
1. Write a C program to find the transpose of a matrix.
2. Write a C program to find the sum of two diagonal elements of a n*n matrx.
3. Write a C program to find the saddle points in a matrix. It is computed as
follows:
Find out the smallest element in a row. The saddle point exists in a row if an
element is the largest element in that corresponding column. Consider the
following example.
7 5 6
10 2 3
1 3 3
In the above 3*3 matrix, in Row1, the saddle point exists at Column2. In
Row2 and Row3, the saddle points does not exist.
4. Write a C program to generate a n*n ( where n is an odd integer ) magic
square such that the sum of any row or column elements must be the same.
Example:
7 5 3
2 9 4
6 1 8

Week 8:
1. Write a User-Defined Function in C to swap two numbers using :
i.

Call By Value

ii.

Call By Reference

2. Write a User-Defined Function in C to print the largest and smallest digit in a


given number.

3. Write a User-Defined Function in C to print all the Triad Numbers below


1000. Triad Numbers have the following properties :
(i) each is a 3 digit number
(ii) each of the digit 1,2,...9 occurs only once in all the 3 numbers.
(iii) the 2nd number is twice the first number and the 3rd number is
thrice that of the first number.
Example : 192, 384, & 576 are Triad Numbers.
4. Write a C program to print the first N Fibonacci Sequence of Numbers using
Recursion. The Recurrence Relation is :
Fibonacci(N) =
Fibonacci(N-

if N <= 1

1) + Fibonacci(N-2)

if N >= 2

5. Write a C program to find the GCD of two numbers using Recursion. The
Recurrence Relation is :
GCD(a, b) =
GCD(b,

a
a mod b)

if b = 0
if b > 0

Week 9:
1. Write a C program for the following string manipulation functions without
using built-in functions.
(i) strcat (ii) strcpy (iii) strcmp (iv) strlen (v) strrev
2. Write a C program to count the number of 3 letter words in a given sequence.
Assume that words are separated by blank space and the sequence is
terminated by a period(.)
3. Write a C program to check whether a String is Palindrome or Not.
Week 10:
1.

Write a C program to sort the names in alphabetical order.

2.

Write a C program to search and find the number of occurrences of a character


in the string.

3.

Write an interactive C program to encode a line of text. The procedure for


Encoding is as follows :

i.

Convert each character, including blank spaces to its ASCII equivalent.

ii.

Generate a positive random integer. Add this integer to the ASCII


equivalent of each character. The same random integer will be used for
all the characters in the entire line of text.

iii.

Suppose that N1 represents the lowest permissible value in the ASCII


code and N2 represents the highest permissible value in the ASCII
code. If the number obtained in the Step 2 above ( i.e., the original
ASCII equivalent + the random integer ) exceeds N2, then subtract the
largest possible multiple of N2 from this number, and add the
remainder to N1. Hence, the encoded number will always fall between
N1 and N2, and will therefore always represent some ASCII character.

iv.

Display the characters that correspond to the encoded ASCII values.

Week 11
1.

Write a C program to arrange the individual digits of a number in descending


order using pointers.

2.

Write a C program to perform multiplication of two matrices using the


concept of Array of Pointers. Define the User-defined Functions to get the
input matrices, to perform matrix multiplication and to display the resultant
matrix.

3.

Write a User-Defined Function in C to perform matrix subtraction using


pointers and return the resultant matrix to the calling function using the
concept of pointer to a function.

Week 12
1. Write a C program to create N number of Student records having the following
fields :

Field Name
Data Type

-------------

-------------

Name

String

RollNo

Integer

Mark

Integer Array of SIZE 5 to store 5


Subject Marks

Total

Integer

Average

Floating Point Number

Sort the Student

records by using Average as a Key.


2. Write a C program to create N number of Employee records having the
following fields :
Field Name

Data Type

---------------

-------------

Name

String

EmpID

Integer

Dept

String

Design

String

BasicPay

Floating Point Number

Get any one Employee id as an input from the created list. For that employee,
calculate the following salary allowances and display all his details.
DA

45 % of BasicPay

HRA =

12 % of Basic Pay

CCA =

Rs 400 /-

GP

( BAsicPay + DA + HRA + CCA )

AP

( GP * 12 )

PF

25 % of BasicPay

NP

GP ( PF + IT )

Calculation of IT(Income Tax):


-------------------------------------i.

IT = 0.0

if AP < 60000

ii.

IT = 0.1 * GP

if AP > 60000 and < = 120000

iii.

IT = 0.2 * GP

if AP > 120000 and < = 180000

iv.

IT = 0.25 * GP

if AP > 180000

Das könnte Ihnen auch gefallen