1. Programs using I/O statements and expressions.
EX.NO:1.A AREA OF CIRCLE
AIM:
To write a C Program to find area of Circle.
ALGORITHM:
1. Start the program.
2. Read radius.
3. Area→P1 * Radius * Radius, PI=3.14
4. Print area
5. Stop.
RESULT:
Thus a C Program for calculating area of circle was executed and the output was verified.
EX.NO:1B TEMPERTURE CONVERTION - CELSIUS TO FAHRENHEIT
AIM:
To write a C Program to convert temperature Celsius to Fahrenheit
ALGORITHM:
1. Start the program.
2. Read temperature in Celsius
3. Fahrenheit=(C*9/5)+32
4. Print temperature in Fahrenheit
5. Stop.
RESULT:
Thus a C Program for converting Celsius to Fahrenheit was executed and the output was
verified.
2. Programs using decision-making constructs.
EXNO: 2. A CHECK THE NUMBER ODD OR EVEN
AIM:
To write a C Program to check a given number is Odd or Even
ALGORITHM:
1. Start the program
2. Take integer variable A
3. Get a value to the variable
4. Perform A modulo 2 and check result if output is 0
5. If true print A is even
6. If false print A is odd
7. Stop
RESULT:
Thus a C Program for checking a number for odd or even was executed and the output was
verified.
EX.NO:2.B FIND ROOTS OF QUADRATIC EQUATION
AIM:
Write a C Program to find the roots of quadratic equation
ALGORITHM:
1. Start
2. Declare variables a, b, c, D, x1, x2, rp and ip;
3. Calculate D
D←b - 4ac
2
4. If D≥0
r1←(-b+√D)/2a
r2←(-b-√D)/2a
Display r1 and r2 as roots.
Else
Calculate real part and imaginary part
rp←b/2a
ip←√(-D)/2a
Display rp+j(ip) and rp-j(ip) as roots
5. Stop
RESULT:
Thus a C Program for finding roots of quadratic equation was executed and the output was
verified.
EX.NO:2.C CALCULATE NET PAY OF THE EMPLOYEE
AIM:
Write a C Program to calculate the net pay of the employee
ALGORITHM:
1. Start
2. Declare variables and initializations
3. Read basic salary from user.
4. Calculate the da and net salary.
5. Display the da and net salary
6. Stop
RESULT:
Thus a C Program using decision-making constructs was executed and the output was
verified..
EX.NO:3 LEAP YEAR OR NOT
AIM:
To Write a C program to find whether the given year is leap year or not.
ALGORITHM:
1. Start the program.
2. Read Year.
3. IF Year%4=0.
Step-3.1 IF Year%100=0.
Step-3.1.1 IF Year%400=0.
Step-3.1.2 Print “Leap Year”.
Step-3.1.3 ELSE Print “Not Leap Year.
Step-3.2
ELSE Print “Leap Year”.
4. Print “Not Leap Year”.
5. Stop.
RESULT:
Thus a C Program for Leap year checking was executed and the output was verified..
EX.NO:4 SIMPLE ARITHMETIC CALCULATOR
AIM:
To write a C program to design a calculator to perform the operations addition, subtraction,
multiplication, division and square of a number.
ALGORITHM:
1. Start the program.
2. Read a, b ,c.
3. Print menu
4. Read choice as ch and pass the choice through switch.
5. switch (ch):
Add
Resut->a+b
print result
subract
Resut->a-b
print result
multiply
resut->a*b
print result
divide
result->a/b
print result
square
result->a*a
result1->b*b
print result
6. Stop
RESULT:
Thus a C Program for Arithmetic operations was executed and the output was verified..
EX.NO:5 ARMSTRONG NUMBER OR NOT
AIM:
To write a C Program to Check whether a given number is Armstrong number or not .
ALGORITHM:
1. Start
2. Declare variables
3. Read the Input number.
4. Separate the digits and calculate cube of individual digits
5. Find the sum of cubes of individual digits.
6. Match the result with input number.
7. If matches, Display the given number is Armstrong otherwise not.
8. Stop
RESULT:
Thus a C Program for Armstrong number checking was executed and the output was
verified..
6. MEAN OF HEIGHTS IN AN ARRAY
AIM:
To calculate average height from an array of different heights and find how many persons
are above the average height.
ALGORITHM:
1. Get the height of a person as input and store them in an array
2. Use a for loop to calculate the sum and average of heights
3. Using if,else statements, categorize the height as above or below average
4. Print the output, the number of persons above average.
4. stop
RESULT:
Thus a C Program average height of persons was executed and the output was verified.
EX.NO:7 COMPUTE BODY MASS INDEX OF THE INDIVIDUALS
AIM:
To write a C Program to Populate a two dimensional array with height and weight of
persons and compute the Body Mass Index of the individuals.
ALGORITHM:
1. Start
2. Declare variables
3. Read the number of persons and their height and weight.
4. Calculate BMI=W/H2 for each person
5. Display the output of the BMI for each person.
6. Stop
RESULT:
Thus a C Program Body Mass Index of the individuals was executed and the output was
obtained.
EX.NO: 8 SORT THE NUMBERS BASED ON THE WEIGHT AND ORDER
AIM:
To write a program to sort given 2-D array of numbers
Data given:
Numbers are given as an array. Give weights to the items based on the following
conditions
5 if it is a perfect cube
4 if it is a multiple of 4 and divisible by 6
3 if it is a prime number
Sort the <number,weight> stored in a 2-D array based on the weight
ALGORITHM:
2. Start
3. Declare variables
4. Read the number of elements
5. Get the individual elements.
6. Calculate the weight for each element by the conditions
5 if it is a perfect cube (pow)
4 if it is a multiple of 4 and divisible by 6 (modulus operator)
3 if it is a prime number(modulus operator)
7. Display the output of the weight calculations after sorting .
8. Stop
RESULT:
Thus a C Program for Sort the numbers based on the weight was executed and the output
was verified.
EX.NO:9 REVERSE A STRING WITHOUT CHANGING THE POSITION
OF SPECIALCHARACTERS.
AIM:
To write a C Program to perform reverse without changing the position of special
characters in the given string.
ALGORITHM:
1. Start
2. Declare variables.
3. Read a String.
4. Check each character of string for alphabets or a special character by using isAlpha() .
5. Change the position of a character vice versa if it is alphabet otherwise remains same.
6. Repeat step 4 until reach to the mid of the position of a string.
7. Display the output of the reverse string without changing the position of special
characters .
8. Stop
RESULT:
Thus a C Program for reverse of a given String was executed and the output was verified.
EX.NO: 10 CONVERTION OF DECIMAL NUMBER INTO BINARY,
OCTAL ANDHEXADECIMAL
AIM:
To write a C Program to Convert the given decimal number into binary, octal and
hexadecimal numbers using user defined functions.
ALGORITHM:
1. Start
2. Declare variables.
3. Read a decimal number.
4. Develop the procedure for conversion of different base by modulus and divide operator.
Repeated division by new base value and the remainder in every division will give
the conversion value.
5. Display the output of the conversion value.
6. Stop
RESULT:
Thus a C Program for conversion of decimal number into other bases was executed and the
output was verified.
EX.NO:11 STRING OPERATIONS
AIM:
To write a C Program to perform string operations on a given paragraph for the following
using built-in functions:
a. Find the total number of words.
b. Capitalize the first word of the sentence.
ALGORITHM:
1. Start
2. Declare variables
3. Read the text.
4. Compare each character with tab char „\t‟ or space char “ “ to count no of words
5. Replace the first charter of each sentence to capitalize letter.
6. Display the output of the process.
8. Stop.
RESULT:
Thus a C Program String operation was executed and the output was verified.
EX.NO:12 SOLVE TOWERS OF HANOI USING RECURSION
AIM:
To write a C Program to Solve towers of Hanoi using recursion.
ALGORITHM:
1. Start
2. Declare variables
3. Read the Input for number of discs.
4. Check the condition for each transfer of discs using recursion.
Move n-1 disks from source to temporary (Recursive Call)
Move nthdisk from Source to Destination (Move)
Move n-1 disks from temporary to destination(Recursive Call)
5. Display the output of the each move(From To) .
6. Stop
RESULT:
Thus a C Program Towers of Hanoi using Recursion was executed and the output was
verified successfully.
EX.NO:13 SORTING USING PASS BY REFERENCE
AIM:
To write a C Program to Sort the list of numbers using pass by reference.
ALGORITHM:
1. Start
2. Declare variables and create an array
3. Read the Input for number of elements and each element.
4. Develop a function to sort the array by passing reference
5. Compare the elements in each pass till all the elements are sorted.
6. Display the output of the sorted elements.
7. Stop
RESULT:
Thus a C Program Sorting using pass by reference was executed and the output was
verified.
EX.NO:14 SALARY SLIP OF EMPLOYEES USING STRUCTURES AND POINTERS
AIM:
To write a C Program to Generate salary slip of employees using structures and pointers..
ALGORITHM:
1. Start
2. Declare variables, Declare structure with required members.
3. Create array of structures to store each employee data
4. Read the number of employees .
5. Read allowances, deductions and basic for each employee.
6. Calculate net pay= (basic+ allowances)-deductions
7. Display the output of the Pay slip calculations for each employee.
8. Stop
RESULT:
Thus a C Program to display Salary slip of employees was executed and the output was
verified.
EX.NO:15 INTERNAL MARKS CALCULATION OF STUDENTS
AIM:
To write a C Program to compute internal marks of students for five different subjects using
structures and functions.
ALGORITHM:
1. Start
2. Declare variables, Declare structure with required members
3. Read the number of students.
4. Read the mark details of every student
5. Calculate internal mark of every student by mark/5 for each subject
6. Display the output of the calculations for all the students .
7. Stop
RESULT:
Thus a C Program Salary slip of employees was executed and the output was verified.
EX.NO:16 SEQUENTIAL FILE ACCESS
AIM:
To write a C Program to find average of numbers stored in a File using sequential access
file.
ALGORITHM:
1.Start
2. Declare variables, File pointer.and phonebook structures.
3. Open the file in read mode.
4. Read the values stroed in the file.
6. Calculate sum and average of values.
7. Display the sum and average.
8. Stop
RESULT:
Thus a C Program to Find average of numbers stored in a File using sequential access file
was executed and the output was verified.
EX.NO:17 BANKING APPLICATION
AIM:
To write a C Program to create account for account holders and to check balance using
random access file.
ALGORITHM:
1. Start
2. Declare variables and file pointer.
3. Display the menu options.
4. Read the Initial balance.
5. Create the account
6. Display the account details..
7. Get the account number
8. Display the balance of the account number.
9 Repeat step 3 until choose to stop.
10. Stop
RESULT:
Thus a C Program for Banking Application was executed and the output was verified..