SlideShare a Scribd company logo
1 of 18
Download to read offline
I PUC Computer Science Lab Manual
Prof. K. Adisesha 1
CONTENTS
Pgm
No
Program Name
Page
No
1 Write a program to interchange the values of two variables
a. Using a third variable. b. Without using a third variable.
2
2 Write a program to find the area and circumference of a circle. 3
3 Write a program to find the area of a triangle given three sides. 3
4 Write a program to convert days into years, months and days. (all months have 30 days) 4
5 Write a program to find the largest, smallest and second largest of three numbers using
simple if statement.
4
6 Write a program to input the total amount in a bill, if the amount is greater than 1000 the
discount of 8% is given otherwise no discount is given, output the total amount, the
discount amount and the final amount, use simple if statement.
5
7 Write a program to check whether a given year is a leap year or not using if- else
statement.
6
8 Write a program to input a character and find out whether it is a lower case or upper case
character using if-else statement.
6
9 Write a program to input the number of units of electricity consumed in a house and
calculate the final amount using nested-if statement. Use the following data for
calculation
7
10 Write a program to input the marks of four subjects, calculate the total percentage and
output the result as either “First class”, or “Second class”, or “Pass class” or “Fails”
using switch statement.
8
11 Write a program to find the sum of all the digits of a number using while statement 9
12 Write a program to input principal amount, rate of interest and time period and calculate
compound interest using while statement. (Hint: CI = P * (1 + R / 100) T).
9
13 Write a program to check whether a given number is a power of 2. 10
14 Write a program to find the factorial of a number using for statement. 10
15 Write a program to generate the Fibonacci sequence up to a limit using for statement. 11
16 Write a program to find the sum and average of “N” numbers. 11
17 Write a program to find the second largest of “N” numbers. 12
18 Write a program to arrange a list of numbers in ascending order. 13
19 Write a program to check whether a given string is a palindrome or not. 13
20 Write a program to find the position of a given number in an array. 14
21 Write a program to sum of all the rows and the sum of all the columns of a matrix
separately
14
22 Write a program to find the sum of two compatible matrices. 15
23 Write a program to count the number of vowels and consonants in a string. 16
24 Write a program to find the GCD and LCM of two numbers using functions. 16
25 Write a program to input the register number, name and class of all the students in a
class into a structure and output the data in a tabular manner with proper heading
17
I PUC Computer Science Lab Manual
Prof. K. Adisesha 2
Section A
C++ Programs
PROGRAM 1(a):
Write a C++ program to interchange the values of two variables using a
third variable.
#include<iostream.h>
#include<conio.h>
void main( )
{
int a, b, temp;
clrscr( );
cout<<"Enter the two numbers";
cin>>a>>b;
cout<<"Before Interchanging : a = " <<a<<" and b = "<<b<<endl;
temp = a;
a = b;
b = temp;
cout<<"After Interchanging : a = " <<a<<" and b = "<<b<<endl;
getch();
}
OUTPUT:
PROGRAM 1(b):
Write a C++ program to interchange the values of two variables without
using third variable.
#include<iostream.h>
#include<conio.h>
void main( )
{
int a, b;
clrscr( );
cout<<"Enter the two numbers:"<<endl;
cin>>a>>b;
cout<<"Before Interchanging : a = " <<a<<" and b = "<<b<<endl;
a = a + b;
b = a - b;
a = a - b;
cout<<"After Interchanging : a = " <<a<<" and b = "<<b<<endl;
getch();
}
OUTPUT:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 3
PROGRAM 2:
Write a C++ program to find the area and circumference of a circle.
#include<iostream.h>
#include<conio.h>
void main( )
{
float rad, area, circum;
clrscr( );
cout<<"Enter the radius:";
cin>>rad;
area = 3.142 * rad * rad;
circum = 2 * 3.142 * rad;
cout<<"Area of circle = "<<area<<endl;
cout<<"Circumference of circle = "<<circum<<endl;
getch();
}
OUTPUT :
PROGRAM 3:
Write a C++ program to find the area of triangle given three sides.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main( )
{
float s1, s2, s3, s, area;
clrscr( );
cout<<"Enter the length of three sides:";
cin>>s1>>s2>>s3;
s = (s1 + s2+ s3)/2;
area = sqrt( s* (s-s1) * (s-s2) * (s-s3));
cout<<"Area of triangle = "<<area<<endl;
getch();
}
OUTPUT :
I PUC Computer Science Lab Manual
Prof. K. Adisesha 4
PROGRAM 4:
Write a C++ program to convert days into years, months and days.
(Hint: Assume all months have 30 days)
#include<iostream.h>
#include<conio.h>
void main( )
{
int totaldays, days, year, month;
clrscr( );
cout<<"Enter the total days:";
cin>>totaldays;
year = totaldays/365;
totaldays = totaldays % 365;
month = totaldays/30;
days = totaldays % 30;
cout<<"Years = "<< years<<endl;
cout<<"Months = "<<month<<endl;
cout<<"Days = "<<days<<endl;
getch();
}
OUTPUT :
PROGRAM 5:
Write a C++ program to find the largest, smallest and second largest of
three numbers using simple if statement.
#include<iostream.h>
#include<conio.h>
void main( )
{
int a, b, c;
int largest, smallest, seclargest;
clrscr( );
cout<<"Enter the three numbers"<<endl;
cin>>a>>b>>c;
largest = a; //Assume first number as largest
if(b>largest)
largest = b;
if(c>largest)
largest = c;
smallest = a; //Assume first number as smallest
if(b<smallest)
smallest = b;
if(c<smallest)
smallest = c;
seclargest = (a + b + c) - (largest + smallest);
I PUC Computer Science Lab Manual
Prof. K. Adisesha 5
cout<<"Smallest Number is = "<<smallest<<endl;
cout<<"Second Largest Number is = "<<seclargest<<endl;
cout<<"Largest Number is = "<< largest<<endl;
getch( );
}
OUTPUT:
PROGRAM 6:
Write a C++ program to input the total amount in a bill, if the amount is
greater than 1000, a discount of 8% is given. Otherwise, no discount is given.
Output the total amount, discount and the final amount. Use simple if statement.
#include<iostream.h>
#include<conio.h>
void main( )
{
float TAmount, discount, FAmount ;
clrscr( );
cout<<"Enter the Total Amount"<<endl;
cin>>TAmount;
discount = 0; //Calculate Discount
if(TAmount>1000)
discount = (8/100.0) * TAmount;
FAmount = TAmount - discount; //Calculate Final Amount
cout<<"Total Amount = "<<TAmount<<endl;
cout<<"Discount = "<<discount<<endl;
cout<<"Final Amount = "<< FAmount<<endl;
getch( );
}
OUTPUT :
I PUC Computer Science Lab Manual
Prof. K. Adisesha 6
PROGRAM 7:
Write a C++ program to check whether a given year is a leap year not,
Using if - else statement.
#include<iostream.h>
#include<conio.h>
void main( )
{
int year ;
clrscr( );
cout<<"Enter the Year in the form YYYY"<<endl;
cin>>year;
if(year%4 ==0 && year%100!=0 || year%400 ==0)
cout<<year<<" is a leap year"<<endl;
else
cout<<year<<" is not leap year"<<endl;
getch( );
}
OUTPUT :
PROGRAM 8:
Write a C++ program to accept a character. Determine whether the
character is a lower-case or upper-case letter.
#include<iostream.h>
#include<conio.h>
void main( )
{
char ch ;
clrscr( );
cout<<"Enter the Character"<<endl;
cin>>ch;
if(ch>= 'A' && ch <='Z')
cout<<ch<<" is an Upper-Case Character"<<endl;
else
if(ch>= 'a' && ch <='z')
cout<<ch<<" is an Lower-Case Character"<<endl;
else
cout<<ch<<" is not an alphabet"<<endl;
getch( );
}
OUTPUT:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 7
PROGRAM 9:
Write a C++ program to input the number of units of electricity consumed in a
house and calculate the final amount using nested-if statement.
Use the following data for calculation.
#include<iostream.h>
#include<conio.h>
void main( )
{
int units ;
float Billamount;
clrscr( );
cout<<"Enter the number of units consumed:"<<endl;
cin>>units;
if(units < 30)
Billamount = units * 3.50 ;
else
if(units < 50)
Billamount = 29 * 3.50 + (units - 29) * 4.25 ;
else
if(units < 100)
Billamount = 29 * 3.50 + 19 * 4.25 + (units - 49) * 5.25 ;
else
Billamount = 29 * 3.50 + 19 * 4.25 + 49 * 5.25 + (units - 99) * 5.85 ;
cout<<"Total Units Consumed ="<<units<<endl;
cout<<"Total Amount = "<<Billamount<<endl;
getch( );
}
OUTPUT:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 8
PROGRAM 10:
Write a C++ program to input the marks of four subjects. Calculate the total
percentage and output the result as either “First Class” or “Second Class” or
“Pass Class” or “Fail” using switch statement.
Class Range (%)
First Class Between 60% to 100%
Second Class Between 50% to 59%
Pass Class Between 40% to 49%
Fail Less than 40%
#include<iostream.h>
#include<conio.h>
void main( )
{
int m1, m2, m3, m4, total, choice;
float per;
clrscr( );
cout<<"Enter the First subject marks:";
cin>>m1;
cout<<"Enter the Second subject marks:";
cin>>m2;
cout<<"Enter the Third subject marks:";
cin>>m3;
cout<<"Enter the Fourth subject marks:";
cin>>m4;
total = m1 + m2 + m3 + m4;
per = total / 4.0;
cout<<"Total Marks = "<<total<<endl;
cout<<"Percentage = "<<per<<endl;
choice = (int) per/10;
cout<<"The result of the student is: "<<endl;
switch(choice)
{
case 10:
case 9:
case 8:
case 7:
case 6: cout<<"First Class "<<endl;
break;
case 5: cout<<"Second Class"<<endl;
break;
case 4: cout<<"Pass Class"<<endl;
break;
default: cout<<"Fail"<<endl;
}
getch( );
}
OUTPUT 1:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 9
PROGRAM 11:
Write a C++ program to find sum of all the digits of a number using while
statement.
#include<iostream.h>
#include<conio.h>
void main( )
{
int num, sum, rem;
clrscr( );
cout<<"Enter the Number"<<endl;
cin>>num;
sum = 0;
while(num!=0)
{
rem = num % 10;
sum = sum + rem;
num = num/10;
}
cout<<"Sum of the digits is "<<sum<<endl;
getch( );
}
PROGRAM 12:
Write a C++ program to input principal amount, rate of interest and time
period. Calculate compound interest using while statement.
(Hint: Amount = P * (1 + R/100)T, Compound Interest = Amount – P)
#include<iostream.h>
#include<conio.h>
void main( )
{
float pri, amt, priamt, rate, ci;
int time, year;
clrscr( );
cout<<"Enter the Principal amount, rate of interest and time:"<<endl;
cin>>pri>>rate>>time;
year = 1;
priamt = pri;
while(year <= time)
{
amt = pri * (1 + rate/100);
pri=amt;
year ++;
}
ci = amt - priamt;
cout<<"Compound Interest = "<<ci<<endl;
cout<<"Net Amount = "<<amt<<endl;
getch( );
}
I PUC Computer Science Lab Manual
Prof. K. Adisesha 10
PROGRAM 13:
Write a C++ program to check whether the given number is power of 2.
#include<iostream.h>
#include<conio.h>
void main( )
{ int num, m, flag;
clrscr( );
cout<<"Enter the Number"<<endl;
cin>>num;
m = num;
flag = 1;
while(num>2)
if(num % 2 ==1)
{
flag = 0;
break;
}
else
num = num/2;
if(flag)
cout<<m<<" is power of 2 "<<endl;
else
cout<<m<<" is not power of 2 "<<endl;
getch( );
}
PROGRAM 14:
Write a C++ program to find the factorial of a number using for statement.
(Hint: 5! = 5 * 4 * 3 * 2 * 1 = 120)
#include<iostream.h>
#include<conio.h>
void main( )
{
int num, fact, i;
clrscr( );
cout<<"Enter the number"<<endl;
cin>>num;
fact = 1;
for( i = 1; i<= num; i++)
fact = fact * i;
cout<<" The factorial of a "<<num<<"! is: "<<fact<<endl;
getch( );
}
OUTPUT :
I PUC Computer Science Lab Manual
Prof. K. Adisesha 11
PROGRAM 15:
Write a C++ program to generate the Fibonacci sequence up to a limit using for
statement. (Hint: 5 = 0 1 1 2 3)
#include<iostream.h>
#include<conio.h>
void main( )
{
int num, first, second, count, third;
clrscr( );
cout<<"Enter the number limit for Fibonacci Series"<<endl;
cin>>num;
first = 0;
second = 1;
cout<<first<<"t"<<second;
third = first + second;
for( count = 2; third<=num; count++)
{
cout<<"t"<<third
first = second;
second = third;
third = first + second;
}
cout<<"n Total terms = "<<count<<endl;
getch( );
}
OUTPUT :
PROGRAM 16:
Write a C++ program to find the sum and average of n number of the array.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main( )
{
int a[50], i, n, sum;
float avg;
clrscr();
cout<<"How many elements?"<<endl;
cin>>n;
cout<<"Enter the elements:"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
sum = 0;
for(i=0; i<n; i++)
sum = sum + a[i];
avg=(float) sum / n;
cout<<"Sum = "<<sum<<endl;
I PUC Computer Science Lab Manual
Prof. K. Adisesha 12
cout<<"Average = "<<avg<<endl;
getch( );
}
OUTPUT:
PROGRAM 17:
Write a C++ program to find the second largest of n number in the array.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main( )
{
int a[50], i, n, largest, secondlar;
clrscr( );
cout<<"How many elements?"<<endl;
cin>>n;
cout<<"Enter the elements:"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
if(a[0] > a[1])
{
largest = a[0];
secondlar = a[1];
}
else
{
largest=a[1];
secondlar=a[0];
}
for(i=2; i<n; i++)
if(a[i] > largest)
{
secondlar = largest;
largest = a[i];
}
else
if(a[i] > secondlar)
secondlar = a[i];
cout<<"Largest = "<<largest<<endl;
cout<<"Second Largest = "<<secondlar<<endl;
getch( );
}
OUTPUT:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 13
PROGRAM 18:
Write a C++ program to arrange a list of numbers in ascending order.
Sorting: The process of arrangement of data items in ascending or descending order is called
sorting.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main( )
{
int a[50], i, temp, j, n;
clrscr( );
cout<<"Enter the number of elements:"<<endl;
cin>>n;
cout<<"Enter the elements:"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
for(i=1; i<n; i++)
{
for(j=0; j<n-i; j++)
if(a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
cout<<"The sorted elements are:"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<"t";
getch( );
}
PROGRAM 19:
Write a C++ program to determine whether the string is a palindrome.
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main( )
{
char s[100], r[100]; //s is the string and r is the reserved string
clrscr( );
cout<<"Enter the String:";
cin.getline(s, 100);
strcpy (r, s); // Copy the characters of the string s to r
strrev (r); // Reverse the characters of the string r
if(strcmpi(s, r) == 0)
cout<<"It is palindrome"<<endl;
else
cout<<"It is not palindrome"<<endl;
getch( );
}
I PUC Computer Science Lab Manual
Prof. K. Adisesha 14
PROGRAM 20:
Write a C++ program to find position of a given number in the array.
Searching: The process of finding the position of a data item in the given collection of data items is
called searching.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main( )
{
int a[50], i, pos, ele, n;
clrscr( );
cout<<"Enter the number of elements:"<<endl;
cin>>n;
cout<<"Enter the elements:"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the search element:"<<endl;
cin>>ele;
pos=-1;
for(i=0; i<n; i++)
if(ele == a[i])
{
pos = i;
break;
}
if(pos >= 0)
cout<<ele<<" is present at position "<<pos<<endl;
else
cout<<ele<<" is not present"<<endl;
getch( );
}
PROGRAM 21:
Write a C++ program to sum of all the row and sum of all the column in
matrices separately.
#include<iostream.h>
#include<conio.h>
void main( )
{
int a[5][5], r, c, i, j, rsum, csum;
clrscr( );
cout << "Enter the order of matrix: ";
cin >> r>>c;
// Storing elements of matrix entered by user.
cout << "Enter elements of the matrix: " << endl;
for (i = 0; i < r; i++)
for (j = 0; j < c; j++)
cin >> a[i][j];
for(i = 0; i < r; i++)
{
I PUC Computer Science Lab Manual
Prof. K. Adisesha 15
rsum = 0;
for(j = 0; j < c; j++)
rsum = rsum + a[i][j];
cout<<"Sum of row no "<<i+1<<" = "<<rsum<<endl;
}
for(i = 0; i < c; i++)
{
csum = 0;
for(j = 0; j < r; j++)
csum = csum + a[j][i];
cout<<"Sum of column no "<<i+1<<" = "<<csum<<endl;
}
getch( );
}
PROGRAM 22:
Write a C++ program to find the sum of two compatible matrices:
#include<iostream.h>
#include<conio.h>
void main( )
{
int a[5][5], b[5][5], sum[5][5], r1, c1, r2, c2, i, j;
clrscr( );
cout << "Enter the order of first matrix: ";
cin >> r1>>c1;
cout << "Enter the order of second matrix: ";
cin >> r2>>c2;
cout << "Enter elements of 1st matrix: " << endl;
for (i = 0; i < r1; i++)
for (j = 0; j < c1; j++)
cin >> a[i][j];
cout << "Enter elements of 2nd matrix: " << endl;
for(i = 0; i < r2; i++)
for(j = 0; j < c2; j++)
cin >> b[i][j];
if ( (r1 == r2) && (c1==c2))
{
for(i = 0; i < r1; i++)
for(j = 0; j < c1; j++)
sum[i][j] = a[i][j] + b[i][j]; // Adding Two matrices
cout << "Sum of two matrix is: " << endl;
for(i = 0; i < r1; i++)
{
for(j = 0; j < c1; j++)
cout << sum[i][j] << "t"; // Displaying the resultant sum matrix.
cout << endl;
} }
else
cout<<"Matrices are not compatible..."<<endl;
getch( );
}
I PUC Computer Science Lab Manual
Prof. K. Adisesha 16
PROGRAM 23:
Write a C++ program to count the number of vowels and consonants in a
string.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main( )
{
char s[100];
int len, i, cons=0, vow=0;
clrscr( );
cout<<"Enter the string:";
cin.getline(s,100);
len=strlen(s);
for(i=0;i<len;i++)
if( isalpha (s[i]) )
switch (toupper (s[i]) )
{
case'A':
case'E':
case'I':
case'O':
case'U': vow++;
break;
default: cons++;
}
cout<<"Number of Vowles:"<<vow<<endl;
cout<<"Number of Consonants:"<<cons<<endl;
getch();
}
PROGRAM 24:
Write a C++ program to find the GCD and LCM of two numbers using
functions.
#include<iostream.h>
#include<conio.h>
void main( )
{
int gcd(int, int); //Function Prototype
int a, b, g, lcm;
clrscr( );
cout<<"Enter two number:"<<endl;
cin>>a>>b;
g = gcd(a,b);
lcm = (a * b)/g;
cout<<"GCD of "<<a<<" and "<<b<<" is "<<g<<endl;
cout<<"LCM of "<<a<<" and "<<b<<" is "<<lcm<<endl;
getch( );
}
I PUC Computer Science Lab Manual
Prof. K. Adisesha 17
int gcd( int x, int y)
{
int rem;
while(y != 0)
{
rem = x % y;
x = y;
y = rem;
}
return(x);
}
PROGRAM 25:
Write a C++ program to input the register number, name and class of all the
students in a class into a structure and output the data in a tabular manner with
proper heading.
#include<iostream.h>
#include<conio.h>
struct student
{
int regno;
char name[15];
char section[4];
};
void main( )
{
student s[50];
int i, j, n;
clrscr( );
cout<<"How many students?"<<endl;
cin>>n;
for(i=0; i<n; i++)
{
cout<<"Enter the Reg No of the Student "<<i+1<<":";
cin>>s[i].regno;
cout<<"Enter the Name of the Student "<<i+1<<":";
cin>>s[i].name;
cout<<"Enter the Class of the Student "<<i+1<<":";
cin>>s[i].section;
}
cout<<"REG_NO t NAME t CLASS t"<<endl;
for(i=0; i<n; i++)
cout<<s[i].regno<<"t"<<s[i].name<<"t"<< s[i].section<<endl;
getch( );
}
OUTPUT:
I PUC Computer Science Lab Manual
Prof. K. Adisesha 18
Section B
(SPREADSHEET & HTML)

More Related Content

What's hot

Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C ProgrammingHimanshu Negi
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming languagesanjay joshi
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programmingprogramming9
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C ProgrammingQazi Shahzad Ali
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c languagesneha2494
 
C and its errors
C and its errorsC and its errors
C and its errorsJunaid Raja
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statementnarmadhakin
 
IF Statement
IF StatementIF Statement
IF StatementYunis20
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowchartsnicky_walters
 

What's hot (20)

Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Introduction to c programming language
Introduction to c programming languageIntroduction to c programming language
Introduction to c programming language
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
C and its errors
C and its errorsC and its errors
C and its errors
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
IF Statement
IF StatementIF Statement
IF Statement
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Loops c++
Loops c++Loops c++
Loops c++
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
History of c
History of cHistory of c
History of c
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 

Similar to I PUC CS Lab_programs

Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileHarjinder Singh
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newLast7693
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newscottbrownnn
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab neweyavagal
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQLvikram mahendra
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy BookAbir Hossain
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
 
C program report tips
C program report tipsC program report tips
C program report tipsHarry Pott
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solvingSyed Umair
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docxrafbolet0
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 

Similar to I PUC CS Lab_programs (20)

Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical File
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
C program report tips
C program report tipsC program report tips
C program report tips
 
c programing
c programingc programing
c programing
 
Cp manual final
Cp manual finalCp manual final
Cp manual final
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Programming qns
Programming qnsProgramming qns
Programming qns
 
Statement
StatementStatement
Statement
 

More from Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfProf. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaProf. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfProf. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 

Recently uploaded (20)

IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

I PUC CS Lab_programs

  • 1. I PUC Computer Science Lab Manual Prof. K. Adisesha 1 CONTENTS Pgm No Program Name Page No 1 Write a program to interchange the values of two variables a. Using a third variable. b. Without using a third variable. 2 2 Write a program to find the area and circumference of a circle. 3 3 Write a program to find the area of a triangle given three sides. 3 4 Write a program to convert days into years, months and days. (all months have 30 days) 4 5 Write a program to find the largest, smallest and second largest of three numbers using simple if statement. 4 6 Write a program to input the total amount in a bill, if the amount is greater than 1000 the discount of 8% is given otherwise no discount is given, output the total amount, the discount amount and the final amount, use simple if statement. 5 7 Write a program to check whether a given year is a leap year or not using if- else statement. 6 8 Write a program to input a character and find out whether it is a lower case or upper case character using if-else statement. 6 9 Write a program to input the number of units of electricity consumed in a house and calculate the final amount using nested-if statement. Use the following data for calculation 7 10 Write a program to input the marks of four subjects, calculate the total percentage and output the result as either “First class”, or “Second class”, or “Pass class” or “Fails” using switch statement. 8 11 Write a program to find the sum of all the digits of a number using while statement 9 12 Write a program to input principal amount, rate of interest and time period and calculate compound interest using while statement. (Hint: CI = P * (1 + R / 100) T). 9 13 Write a program to check whether a given number is a power of 2. 10 14 Write a program to find the factorial of a number using for statement. 10 15 Write a program to generate the Fibonacci sequence up to a limit using for statement. 11 16 Write a program to find the sum and average of “N” numbers. 11 17 Write a program to find the second largest of “N” numbers. 12 18 Write a program to arrange a list of numbers in ascending order. 13 19 Write a program to check whether a given string is a palindrome or not. 13 20 Write a program to find the position of a given number in an array. 14 21 Write a program to sum of all the rows and the sum of all the columns of a matrix separately 14 22 Write a program to find the sum of two compatible matrices. 15 23 Write a program to count the number of vowels and consonants in a string. 16 24 Write a program to find the GCD and LCM of two numbers using functions. 16 25 Write a program to input the register number, name and class of all the students in a class into a structure and output the data in a tabular manner with proper heading 17
  • 2. I PUC Computer Science Lab Manual Prof. K. Adisesha 2 Section A C++ Programs PROGRAM 1(a): Write a C++ program to interchange the values of two variables using a third variable. #include<iostream.h> #include<conio.h> void main( ) { int a, b, temp; clrscr( ); cout<<"Enter the two numbers"; cin>>a>>b; cout<<"Before Interchanging : a = " <<a<<" and b = "<<b<<endl; temp = a; a = b; b = temp; cout<<"After Interchanging : a = " <<a<<" and b = "<<b<<endl; getch(); } OUTPUT: PROGRAM 1(b): Write a C++ program to interchange the values of two variables without using third variable. #include<iostream.h> #include<conio.h> void main( ) { int a, b; clrscr( ); cout<<"Enter the two numbers:"<<endl; cin>>a>>b; cout<<"Before Interchanging : a = " <<a<<" and b = "<<b<<endl; a = a + b; b = a - b; a = a - b; cout<<"After Interchanging : a = " <<a<<" and b = "<<b<<endl; getch(); } OUTPUT:
  • 3. I PUC Computer Science Lab Manual Prof. K. Adisesha 3 PROGRAM 2: Write a C++ program to find the area and circumference of a circle. #include<iostream.h> #include<conio.h> void main( ) { float rad, area, circum; clrscr( ); cout<<"Enter the radius:"; cin>>rad; area = 3.142 * rad * rad; circum = 2 * 3.142 * rad; cout<<"Area of circle = "<<area<<endl; cout<<"Circumference of circle = "<<circum<<endl; getch(); } OUTPUT : PROGRAM 3: Write a C++ program to find the area of triangle given three sides. #include<iostream.h> #include<conio.h> #include<math.h> void main( ) { float s1, s2, s3, s, area; clrscr( ); cout<<"Enter the length of three sides:"; cin>>s1>>s2>>s3; s = (s1 + s2+ s3)/2; area = sqrt( s* (s-s1) * (s-s2) * (s-s3)); cout<<"Area of triangle = "<<area<<endl; getch(); } OUTPUT :
  • 4. I PUC Computer Science Lab Manual Prof. K. Adisesha 4 PROGRAM 4: Write a C++ program to convert days into years, months and days. (Hint: Assume all months have 30 days) #include<iostream.h> #include<conio.h> void main( ) { int totaldays, days, year, month; clrscr( ); cout<<"Enter the total days:"; cin>>totaldays; year = totaldays/365; totaldays = totaldays % 365; month = totaldays/30; days = totaldays % 30; cout<<"Years = "<< years<<endl; cout<<"Months = "<<month<<endl; cout<<"Days = "<<days<<endl; getch(); } OUTPUT : PROGRAM 5: Write a C++ program to find the largest, smallest and second largest of three numbers using simple if statement. #include<iostream.h> #include<conio.h> void main( ) { int a, b, c; int largest, smallest, seclargest; clrscr( ); cout<<"Enter the three numbers"<<endl; cin>>a>>b>>c; largest = a; //Assume first number as largest if(b>largest) largest = b; if(c>largest) largest = c; smallest = a; //Assume first number as smallest if(b<smallest) smallest = b; if(c<smallest) smallest = c; seclargest = (a + b + c) - (largest + smallest);
  • 5. I PUC Computer Science Lab Manual Prof. K. Adisesha 5 cout<<"Smallest Number is = "<<smallest<<endl; cout<<"Second Largest Number is = "<<seclargest<<endl; cout<<"Largest Number is = "<< largest<<endl; getch( ); } OUTPUT: PROGRAM 6: Write a C++ program to input the total amount in a bill, if the amount is greater than 1000, a discount of 8% is given. Otherwise, no discount is given. Output the total amount, discount and the final amount. Use simple if statement. #include<iostream.h> #include<conio.h> void main( ) { float TAmount, discount, FAmount ; clrscr( ); cout<<"Enter the Total Amount"<<endl; cin>>TAmount; discount = 0; //Calculate Discount if(TAmount>1000) discount = (8/100.0) * TAmount; FAmount = TAmount - discount; //Calculate Final Amount cout<<"Total Amount = "<<TAmount<<endl; cout<<"Discount = "<<discount<<endl; cout<<"Final Amount = "<< FAmount<<endl; getch( ); } OUTPUT :
  • 6. I PUC Computer Science Lab Manual Prof. K. Adisesha 6 PROGRAM 7: Write a C++ program to check whether a given year is a leap year not, Using if - else statement. #include<iostream.h> #include<conio.h> void main( ) { int year ; clrscr( ); cout<<"Enter the Year in the form YYYY"<<endl; cin>>year; if(year%4 ==0 && year%100!=0 || year%400 ==0) cout<<year<<" is a leap year"<<endl; else cout<<year<<" is not leap year"<<endl; getch( ); } OUTPUT : PROGRAM 8: Write a C++ program to accept a character. Determine whether the character is a lower-case or upper-case letter. #include<iostream.h> #include<conio.h> void main( ) { char ch ; clrscr( ); cout<<"Enter the Character"<<endl; cin>>ch; if(ch>= 'A' && ch <='Z') cout<<ch<<" is an Upper-Case Character"<<endl; else if(ch>= 'a' && ch <='z') cout<<ch<<" is an Lower-Case Character"<<endl; else cout<<ch<<" is not an alphabet"<<endl; getch( ); } OUTPUT:
  • 7. I PUC Computer Science Lab Manual Prof. K. Adisesha 7 PROGRAM 9: Write a C++ program to input the number of units of electricity consumed in a house and calculate the final amount using nested-if statement. Use the following data for calculation. #include<iostream.h> #include<conio.h> void main( ) { int units ; float Billamount; clrscr( ); cout<<"Enter the number of units consumed:"<<endl; cin>>units; if(units < 30) Billamount = units * 3.50 ; else if(units < 50) Billamount = 29 * 3.50 + (units - 29) * 4.25 ; else if(units < 100) Billamount = 29 * 3.50 + 19 * 4.25 + (units - 49) * 5.25 ; else Billamount = 29 * 3.50 + 19 * 4.25 + 49 * 5.25 + (units - 99) * 5.85 ; cout<<"Total Units Consumed ="<<units<<endl; cout<<"Total Amount = "<<Billamount<<endl; getch( ); } OUTPUT:
  • 8. I PUC Computer Science Lab Manual Prof. K. Adisesha 8 PROGRAM 10: Write a C++ program to input the marks of four subjects. Calculate the total percentage and output the result as either “First Class” or “Second Class” or “Pass Class” or “Fail” using switch statement. Class Range (%) First Class Between 60% to 100% Second Class Between 50% to 59% Pass Class Between 40% to 49% Fail Less than 40% #include<iostream.h> #include<conio.h> void main( ) { int m1, m2, m3, m4, total, choice; float per; clrscr( ); cout<<"Enter the First subject marks:"; cin>>m1; cout<<"Enter the Second subject marks:"; cin>>m2; cout<<"Enter the Third subject marks:"; cin>>m3; cout<<"Enter the Fourth subject marks:"; cin>>m4; total = m1 + m2 + m3 + m4; per = total / 4.0; cout<<"Total Marks = "<<total<<endl; cout<<"Percentage = "<<per<<endl; choice = (int) per/10; cout<<"The result of the student is: "<<endl; switch(choice) { case 10: case 9: case 8: case 7: case 6: cout<<"First Class "<<endl; break; case 5: cout<<"Second Class"<<endl; break; case 4: cout<<"Pass Class"<<endl; break; default: cout<<"Fail"<<endl; } getch( ); } OUTPUT 1:
  • 9. I PUC Computer Science Lab Manual Prof. K. Adisesha 9 PROGRAM 11: Write a C++ program to find sum of all the digits of a number using while statement. #include<iostream.h> #include<conio.h> void main( ) { int num, sum, rem; clrscr( ); cout<<"Enter the Number"<<endl; cin>>num; sum = 0; while(num!=0) { rem = num % 10; sum = sum + rem; num = num/10; } cout<<"Sum of the digits is "<<sum<<endl; getch( ); } PROGRAM 12: Write a C++ program to input principal amount, rate of interest and time period. Calculate compound interest using while statement. (Hint: Amount = P * (1 + R/100)T, Compound Interest = Amount – P) #include<iostream.h> #include<conio.h> void main( ) { float pri, amt, priamt, rate, ci; int time, year; clrscr( ); cout<<"Enter the Principal amount, rate of interest and time:"<<endl; cin>>pri>>rate>>time; year = 1; priamt = pri; while(year <= time) { amt = pri * (1 + rate/100); pri=amt; year ++; } ci = amt - priamt; cout<<"Compound Interest = "<<ci<<endl; cout<<"Net Amount = "<<amt<<endl; getch( ); }
  • 10. I PUC Computer Science Lab Manual Prof. K. Adisesha 10 PROGRAM 13: Write a C++ program to check whether the given number is power of 2. #include<iostream.h> #include<conio.h> void main( ) { int num, m, flag; clrscr( ); cout<<"Enter the Number"<<endl; cin>>num; m = num; flag = 1; while(num>2) if(num % 2 ==1) { flag = 0; break; } else num = num/2; if(flag) cout<<m<<" is power of 2 "<<endl; else cout<<m<<" is not power of 2 "<<endl; getch( ); } PROGRAM 14: Write a C++ program to find the factorial of a number using for statement. (Hint: 5! = 5 * 4 * 3 * 2 * 1 = 120) #include<iostream.h> #include<conio.h> void main( ) { int num, fact, i; clrscr( ); cout<<"Enter the number"<<endl; cin>>num; fact = 1; for( i = 1; i<= num; i++) fact = fact * i; cout<<" The factorial of a "<<num<<"! is: "<<fact<<endl; getch( ); } OUTPUT :
  • 11. I PUC Computer Science Lab Manual Prof. K. Adisesha 11 PROGRAM 15: Write a C++ program to generate the Fibonacci sequence up to a limit using for statement. (Hint: 5 = 0 1 1 2 3) #include<iostream.h> #include<conio.h> void main( ) { int num, first, second, count, third; clrscr( ); cout<<"Enter the number limit for Fibonacci Series"<<endl; cin>>num; first = 0; second = 1; cout<<first<<"t"<<second; third = first + second; for( count = 2; third<=num; count++) { cout<<"t"<<third first = second; second = third; third = first + second; } cout<<"n Total terms = "<<count<<endl; getch( ); } OUTPUT : PROGRAM 16: Write a C++ program to find the sum and average of n number of the array. #include<iostream.h> #include<conio.h> #include<iomanip.h> void main( ) { int a[50], i, n, sum; float avg; clrscr(); cout<<"How many elements?"<<endl; cin>>n; cout<<"Enter the elements:"<<endl; for(i=0; i<n; i++) cin>>a[i]; sum = 0; for(i=0; i<n; i++) sum = sum + a[i]; avg=(float) sum / n; cout<<"Sum = "<<sum<<endl;
  • 12. I PUC Computer Science Lab Manual Prof. K. Adisesha 12 cout<<"Average = "<<avg<<endl; getch( ); } OUTPUT: PROGRAM 17: Write a C++ program to find the second largest of n number in the array. #include<iostream.h> #include<conio.h> #include<iomanip.h> void main( ) { int a[50], i, n, largest, secondlar; clrscr( ); cout<<"How many elements?"<<endl; cin>>n; cout<<"Enter the elements:"<<endl; for(i=0; i<n; i++) cin>>a[i]; if(a[0] > a[1]) { largest = a[0]; secondlar = a[1]; } else { largest=a[1]; secondlar=a[0]; } for(i=2; i<n; i++) if(a[i] > largest) { secondlar = largest; largest = a[i]; } else if(a[i] > secondlar) secondlar = a[i]; cout<<"Largest = "<<largest<<endl; cout<<"Second Largest = "<<secondlar<<endl; getch( ); } OUTPUT:
  • 13. I PUC Computer Science Lab Manual Prof. K. Adisesha 13 PROGRAM 18: Write a C++ program to arrange a list of numbers in ascending order. Sorting: The process of arrangement of data items in ascending or descending order is called sorting. #include<iostream.h> #include<conio.h> #include<iomanip.h> void main( ) { int a[50], i, temp, j, n; clrscr( ); cout<<"Enter the number of elements:"<<endl; cin>>n; cout<<"Enter the elements:"<<endl; for(i=0; i<n; i++) cin>>a[i]; for(i=1; i<n; i++) { for(j=0; j<n-i; j++) if(a[j] > a[j+1]) { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } cout<<"The sorted elements are:"<<endl; for(i=0; i<n; i++) cout<<a[i]<<"t"; getch( ); } PROGRAM 19: Write a C++ program to determine whether the string is a palindrome. #include<iostream.h> #include<conio.h> #include<string.h> void main( ) { char s[100], r[100]; //s is the string and r is the reserved string clrscr( ); cout<<"Enter the String:"; cin.getline(s, 100); strcpy (r, s); // Copy the characters of the string s to r strrev (r); // Reverse the characters of the string r if(strcmpi(s, r) == 0) cout<<"It is palindrome"<<endl; else cout<<"It is not palindrome"<<endl; getch( ); }
  • 14. I PUC Computer Science Lab Manual Prof. K. Adisesha 14 PROGRAM 20: Write a C++ program to find position of a given number in the array. Searching: The process of finding the position of a data item in the given collection of data items is called searching. #include<iostream.h> #include<conio.h> #include<iomanip.h> void main( ) { int a[50], i, pos, ele, n; clrscr( ); cout<<"Enter the number of elements:"<<endl; cin>>n; cout<<"Enter the elements:"<<endl; for(i=0; i<n; i++) cin>>a[i]; cout<<"Enter the search element:"<<endl; cin>>ele; pos=-1; for(i=0; i<n; i++) if(ele == a[i]) { pos = i; break; } if(pos >= 0) cout<<ele<<" is present at position "<<pos<<endl; else cout<<ele<<" is not present"<<endl; getch( ); } PROGRAM 21: Write a C++ program to sum of all the row and sum of all the column in matrices separately. #include<iostream.h> #include<conio.h> void main( ) { int a[5][5], r, c, i, j, rsum, csum; clrscr( ); cout << "Enter the order of matrix: "; cin >> r>>c; // Storing elements of matrix entered by user. cout << "Enter elements of the matrix: " << endl; for (i = 0; i < r; i++) for (j = 0; j < c; j++) cin >> a[i][j]; for(i = 0; i < r; i++) {
  • 15. I PUC Computer Science Lab Manual Prof. K. Adisesha 15 rsum = 0; for(j = 0; j < c; j++) rsum = rsum + a[i][j]; cout<<"Sum of row no "<<i+1<<" = "<<rsum<<endl; } for(i = 0; i < c; i++) { csum = 0; for(j = 0; j < r; j++) csum = csum + a[j][i]; cout<<"Sum of column no "<<i+1<<" = "<<csum<<endl; } getch( ); } PROGRAM 22: Write a C++ program to find the sum of two compatible matrices: #include<iostream.h> #include<conio.h> void main( ) { int a[5][5], b[5][5], sum[5][5], r1, c1, r2, c2, i, j; clrscr( ); cout << "Enter the order of first matrix: "; cin >> r1>>c1; cout << "Enter the order of second matrix: "; cin >> r2>>c2; cout << "Enter elements of 1st matrix: " << endl; for (i = 0; i < r1; i++) for (j = 0; j < c1; j++) cin >> a[i][j]; cout << "Enter elements of 2nd matrix: " << endl; for(i = 0; i < r2; i++) for(j = 0; j < c2; j++) cin >> b[i][j]; if ( (r1 == r2) && (c1==c2)) { for(i = 0; i < r1; i++) for(j = 0; j < c1; j++) sum[i][j] = a[i][j] + b[i][j]; // Adding Two matrices cout << "Sum of two matrix is: " << endl; for(i = 0; i < r1; i++) { for(j = 0; j < c1; j++) cout << sum[i][j] << "t"; // Displaying the resultant sum matrix. cout << endl; } } else cout<<"Matrices are not compatible..."<<endl; getch( ); }
  • 16. I PUC Computer Science Lab Manual Prof. K. Adisesha 16 PROGRAM 23: Write a C++ program to count the number of vowels and consonants in a string. #include<iostream.h> #include<conio.h> #include<string.h> #include<ctype.h> void main( ) { char s[100]; int len, i, cons=0, vow=0; clrscr( ); cout<<"Enter the string:"; cin.getline(s,100); len=strlen(s); for(i=0;i<len;i++) if( isalpha (s[i]) ) switch (toupper (s[i]) ) { case'A': case'E': case'I': case'O': case'U': vow++; break; default: cons++; } cout<<"Number of Vowles:"<<vow<<endl; cout<<"Number of Consonants:"<<cons<<endl; getch(); } PROGRAM 24: Write a C++ program to find the GCD and LCM of two numbers using functions. #include<iostream.h> #include<conio.h> void main( ) { int gcd(int, int); //Function Prototype int a, b, g, lcm; clrscr( ); cout<<"Enter two number:"<<endl; cin>>a>>b; g = gcd(a,b); lcm = (a * b)/g; cout<<"GCD of "<<a<<" and "<<b<<" is "<<g<<endl; cout<<"LCM of "<<a<<" and "<<b<<" is "<<lcm<<endl; getch( ); }
  • 17. I PUC Computer Science Lab Manual Prof. K. Adisesha 17 int gcd( int x, int y) { int rem; while(y != 0) { rem = x % y; x = y; y = rem; } return(x); } PROGRAM 25: Write a C++ program to input the register number, name and class of all the students in a class into a structure and output the data in a tabular manner with proper heading. #include<iostream.h> #include<conio.h> struct student { int regno; char name[15]; char section[4]; }; void main( ) { student s[50]; int i, j, n; clrscr( ); cout<<"How many students?"<<endl; cin>>n; for(i=0; i<n; i++) { cout<<"Enter the Reg No of the Student "<<i+1<<":"; cin>>s[i].regno; cout<<"Enter the Name of the Student "<<i+1<<":"; cin>>s[i].name; cout<<"Enter the Class of the Student "<<i+1<<":"; cin>>s[i].section; } cout<<"REG_NO t NAME t CLASS t"<<endl; for(i=0; i<n; i++) cout<<s[i].regno<<"t"<<s[i].name<<"t"<< s[i].section<<endl; getch( ); } OUTPUT:
  • 18. I PUC Computer Science Lab Manual Prof. K. Adisesha 18 Section B (SPREADSHEET & HTML)