Screenshot 2024-12-18 at 9.34.35 AM
Screenshot 2024-12-18 at 9.34.35 AM
CS 1 PRACTICALS
PRACTICAL-1 INPUT:
OR
PRACTICAL 1 INPUT :
#include<iostream.h>
#include<conio.h>
void swap(int *,int *);
void main()
{
clrscr();
int a=1,b=2;
cout<<"\n a="<<a<<" "<<"b="<<b;
swap( &a, &b);
cout<<”\n a=”<<a<<” “<<”b= “<<b;
getch();
}
void swap (int *a, int *b)
{
int c;
c=*a;
*a=*b;
*b=*c;
}
PRACTICAL-1 OUTPUT:
PRACTICAL 2 INPUT:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int n,n1,d,s=0;
cout<<"\n Enter a number:";
cin>>n;
n1=n;
while(n>0)
{
d=n%10;
s=(s+pow(d,3));
n=n/10;
}
if(n1==s)
{
cout<<"\n It is an Armstrong number";
}
else
{
cout<<"\n It is not an armstrong number";
}
getch();
}
PRACTICAL 2 OUTPUT:
PRACTICAL 3 INPUT :
/*Aim : Write a program in C++ with the help of ratio class using member
functions like assign() function to initialise its members data, convert()
function to convert ratio into double(), invert() function to get inverse
of the ratio and print function to get the ratio and reciprocal*/
#include<iostream.h>
#include<conio.h>
class ratio
{
private:
float num,den,f,ref;
double n;
public:
void assign();
void convert();
void invert();
void print();
};
void ratio::assign()
{
cout<<"Enter the numerator of the ratio \n";
cin>>num;
cout<<"Enter the denominator of the ratio \n";
cin>>den;
f=(float)num/den;
}
void ratio::convert()
{
n=f;
}
void ratio::invert()
{
ref =1/f;
}
void ratio::print()
{
cout<<"Original ratio : "<<f<<endl;
cout<<"Reciprocal ratio :"<<ref<<endl;
}
void main()
{
clrscr();
ratio r1;
r1.assign();
r1.convert();
r1.invert();
r1.print();
getch();
}
PRACTICAL 3 OUTPUT:
PRACTICAL 4 INPUT:
/*program 4:
Aim : Implement a circle class in C++ each object will represent a circle
storing its radius and x and y coordinates and centre as float include a
default constructor, access function() and an area function()
and circumference function() the program must print the coordinates with
radius area and circumference of the circle */
#include<conio.h>
#include<iostream.h>
class circle
{
private:
float x,y,pi,rad;
public:
circle()
{
pi=3.14;
}
void accept()
{
cout<<"Enter x coordinate \n";
cin>>x;
cout<<"Enter y coordinate \n";
cin>>y;
cout<<"Enter the radius \n";
cin>>rad;
}
void display()
{
cout<<"\nX coordinate of the circle is = "<<x<<endl;
cout<<"Y coordinate of circle is = "<<y<<endl;
}
void area()
{
float ar= pi*rad*rad;
cout<<"\n Area of circle is = "<<ar;
}
void circum()
{
float cr= 2*pi*rad;
cout<< "\n Circumference is ="<<cr;
}
};
void main()
{
clrscr();
circle c;
c.accept();
c.display();
c.display();
c.area();
c.circum();
getch();
}
PRACTICAL 4 OUTPUT:
PRACTICAL 5 INPUT :
/*Program 5 aim: Write a program in C++ with a complex constructor to add the given two
complex .A=____ and B=____. the program should print the given complex no and their sum.*/
#include<iostream.h>
#include<conio.h>
class complex
{
private:
float x;//real
float y;//imaginaery
public:
complex(){}
complex(float real, float imag)
{
x=real;
y=imag;
}
void display()
{
cout<<x<<"+"<<y<<"i\n";
}
complex operator + (complex c)
{
complex temp;
temp.x=x+c.x;
temp.y=y+c.y;
return (temp);
}
};
void main()
{
clrscr();
complex c1,c2,c3;
c1=complex(3.2,2.5);
c2=complex(4.5,2.5);
c3=c1+c2;
cout<<"First object:";
c1.display();
cout<<"Second object:";
c2.display();
cout<<"\nResult:";
c3.display();
getch();
}
PRACTICAL 5 OUTPUT :
/* PRACTICAL 6 :
Aim : write program in c++ using a virtual function. The program must declare P to a pointer to
objetcs of the base class person first the program must assign p to a point at an instance y (name of
the student, eg"tom") of derived classes student. Define a print function in the same base class
function to print the name of the student.*/
#include<iostream.h>
#include<conio.h>
class person
{
public:
virtual void print()
{
cout<<"\nName of the person assigned through base object is BOB"<<endl;
}
};
PROGRAM 6 OUTPUT:
PRACTICAL 7 INPUT:
aim: write a program in c++ that initialises a ratio class with no parameters as a default constructor.
the program must print the message "object is born" during initialising it.it should display the
msg "now x i alive" when the first member function ratio is called.the program display"object dies"
when class defination is end of its object when it reaches the end of its scope*/
#include<iostream.h>
#include <conio.h>
class ratio
public:
ratio()
~ratio()
};
void main()
clrscr();
ratio x;
getch();
Practical 7 output
PRACTICAL 7 OUTPUT :
Practical 8
Aim: Write a program to implement function overloading.
#include<iostream.h>
#include<conio.h>
class demo
{
int a,b;
public:
void show()
{
cout<<"\n Hello My Friend";
}
void show(int x,int y)
{
a=x;
b=y;
cout<<"\n a="<<a<<" "<<"b="<<b;
}
};
void main()
{
clrscr();
demo d;
d.show();
d.show(10,20);
getch();
}
OUTPUT:
EXP-9
Program:
<HTML>
<head>
<title>
NMFC college
</title>
</head>
<body bgcolor="yellow">
<a href="www.google.co.in"> click here </a>
<p>
<font color="red" size="5">
Nirmala Memorial Foundation College of Commerce and Science, aflourishing institution
affiliated to the
University of Mumbai made its humble genesis in 2003, through theenlightened vision and
guidance of Mr.
Thakurbhai Desai.
</font>
</p>
<p>
<font color="blue" size="6">
The eight storied building includes modern air-conditioned officeblocks, well equipped
classrooms, well
ease of access of the iPhone. The new UI makes sure that you can usethis amazing technology to
its best. All
the new OS updates of IOS (iPhone Operating System) will be availableas soon as they are
developed.
</font>
</p>
<tr align="center">
<th>Processor
<td colspan="2">A8 processor chip
<td>A7
<td>A6
</tr>
<tr align="center">
<th>Video Recording
<td>1080p HD 120 fps
<td>720p 60 fps
<td colspan="2">720p 30 fps
</tr>
<tr align="center">
<th>Graphic Processor
<td>M8 Motion Co-processor
<td colspan="2">M7
<td>M6
</tr>
<tr align="left">
<th>Additional Features:
<ul type="disc">
<li>Gyrometer
<li>Magnetic sensor
<li>Ambient Light Sensor
<td><br>
Yes<br>
Yes<br>
Yes<br>
<td><br>
Yes<br>
Yes<br>
No<br>
<td colspan="2">
<br>
Yes<br>
No<br>
No<br>
</tr>
<tr>
<th>Price
<td> <ul type="circle">
<li> 32 GB $550
<li> 64 GB $600
<li> 128 GB $650
<center>
<a href="www.apple.com">
<img src=Sunset.jpg size="50%" alt="Sunset" height="250">
</a>
</center>
</body>
</html>
OUTPUT:
EXP-11
Aim: Write a simple VB Script to do the following task whenexecuted:
Collect Information of Name, Date of Birth and Gender from anindividual.
Using Date of birth, calculate the age.
If page 15 16 years or less, then ask for Name or School, if age is morethan 16 years but less
than or equal to 22 years then ask for Name ofCollege and if age is grater then 22 years then ask
for name of the individual’s workplace.
Display a page based on all the above information that would display, the Individuals Name,
Date of Birth, Gender as well as the appropriateEntry made as mentioned in Point iii).
Program:
<html>
<body>
<script language="vbscript">dim
name,age,gender,sc
name=inputbox("Enter ur name") document.write"your name is
",name,"<br>" gender=inputbox("Enter gender")
document.write"your gender is ",gender,"<br>"
bdate=inputbox("enter your birth date like 16-May-1998")
age=datediff("YYYY",bdate,date())
document.write "your Age is ",age,"<br>"
if(age<16)then
sc=inputbox("enter your school name ") document.write"your school
name is",ucase(sc)else if(age<22)then
sc=inputbox("enter your college name") document.write"your
college name is ",ucase(sc)else
sc=inputbox("enter your workplace name") document.write"your
workplace name is",ucase(sc)end if
end if
</script>
</body>
</html>
OUTPUT:
SHREE L R TIWARI JR COLLEGE OF COMMERCE AND SCIENCE
SCIENCE DEPARTMENT
PRACTIICALS OF CS-1/SYJC/2023-2024
EXP-12
Aim: Write a program in Visual Basic that calculates area andselections of two shapes,
Circle and Rectangle.
Program:
Private Sub Command1_Click()
Frame1.Visible = True Frame2.Visible =
False
Text2.Text = Val(3.142 * Text1.Text * Text1.Text)End Sub
Private Sub Command2_Click()Text1.Text
= ""
Text2.Text = ""
Frame1.Visible = True
Frame2.Visible = TrueEnd
Sub
Private Sub Command3_Click()
Frame1.Visible = False Frame2.Visible =
True
Text5.Text = Text3.Text * Text4.TextEnd Sub
Private Sub Command4_Click()Text3.Text
=""
Text4.Text = " " Text5.Text
= "" Frame1.Visible = True
Frame2.Visible = TrueEnd
Sub
SHREE L R TIWARI JR COLLEGE OF COMMERCE AND SCIENCE
SCIENCE DEPARTMENT
PRACTIICALS OF CS-1/SYJC/2023-2024
OUTPUT: