SYBBA (CA) Sem-IV Practical Slip-1
SYBBA (CA) Sem-IV Practical Slip-1
SYBBA (CA) Sem-IV Practical Slip-1
SLIP 1
Q.1
a)
#include<iostream.h>
int main()
int a,b;
cout<<”Enter 2 numbers”<<endl;
cout<<”Number 1:”;
cin>>a;
cout<<”Number 2:”;
cin>>b;
return 0;
b)
Q.2
a)
const readline=require(‘readline’);
const rl=readline.createInterface({
input:process.stdin,
output:process.stdout
});
const upperCaseString=inputString.toUpperCase();
console.log(‘Uppercase Output:’,upperCaseString);
rl.close();
});
b)
slip1db.js
let mysql=require("mysql");
let con=mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
port: "3306",
});
con.connect(function(err){
if (err) {
console.log(err);
} else {
console.log("connected");
});
console.log("Database Created");
});
slip1table.js
let mysql=require("mysql");
let con=mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
port: "3306",
database: “studentdb”
});
con.connect(function(err){
if (err) {
console.log(err);
} else {
console.log("connected");
});
con.query(sql,function(err,result){
console.log(“Table Created”);
});
SLIP 2
Q.1
a)
#include<iostream.h>
return (3.14*r*2*h);
return (3.14*2*h/3);
return (4/3*3.14*r*r*r);
}
int main()
float cy_h,cy_r,co_h,co_r,sp_r;
cout<<”Enter dimensions”<<endl;
cout<<”1.Cyclinder”<<endl;
cout<<”Height:”;
cin>>cy_h;
cout<<”Radius:”;
cin>>cy_r;
cout<<endl;
cout<<”2.Cone”<<endl;
cout<<”Height:”;
cin>>co_h;
cout<<”Radius:”;
cin>>co_r;
cout<<endl;
cout<<”3.Sphere”<<endl;
cout<<”Radius:”;
cin>>sp_r;
cout<<endl;
return 0;
b)
Q.2
a)
fact.js
var fact={
factorial:function(n){
var f=1,i;
for(i=0;i<=n;i++){
f=f*i;
module.exports=fact;
app.js
var mymod=require(‘fact.js’);
mymod.factorial(5);
b)
validate.js
function Dob(dob){
return dobDate.getTime()?dobDate:null;
function Jdate(jdate){
return joinDate.getTime()?joinDate:null;
function Salary(salary){
return salary>0;
module.exports={Dob,Jdate,Salary};
slip2.js
const http=require('http');
const qs=require('querystring');
const {Dob,Jdate,Salary}=require('./validate');
const server=http.createServer((req,res)=>
if(req.method=='GET'&&req.url=='/register')
res.writeHead(200,{'Content-Type':'text/html'});
res.end(`
Name:
Email:
Department:
Date Of Birth:
Joining Date:
Salary:
<button type="submit">Register</button>
</form>
`);
else if(req.method=='POST'&&req.url=='/register')
let body='';
req.on('data',(data)=>
body=body+data;
});
req.on('end',()=>
const formData=qs.parse(body);
const name=formData.name;
const email=formData.email;
const department=formData.department;
const dob=formData.bdate;
const jdate=formData.jdate;
const salary=formData.salary;
if(!Dob(dob))
return;
if(!Jdate(jdate))
return;
if(!Salary(salary))
res.end('Invalid Salary');
return;
console.log(`Employee Registered:
Name: ${name}
Email: ${email}
Department: ${department}
Salary: ${salary}`);
});
else
{
res.writeHead(404,{ 'Content-Type':'text/plain'});
res.end('Not Found');
}).listen(3030);
console.log("Successfully Run.");
SLIP 3
Q.1
a)
#include<iostream.h>
int temp;
temp=a;
a=b;
b=temp;
int main(){
int a,b;
cin>>a;
cin>>b;
cout<<endl<<”Original Numbers”<<endl<<”a=”<<a<<”&b=”<<b<<endl;
swap(a,b);
return 0;
b)
Q.2
a)
circle.js
const PIE=3.14;
function area(r){
return PIE*r*r;
};
function circum(r){
return 2*PIE*r;
};
module.exports={area,circum};
app.js
let app=require("./circle");
const readline=require('readline');
const rl=readline.createInterface({
input:process.stdin,
output:process.stdout
});
rl.question('Enter a radius:',(r)=>{
});
b)
validate1.js
function Name(name)
return name.match(/^[A-Za-z]+$/)!=null;
function Email(email)
return email.includes('@')&&email.includes('.');
}
function Dob(dob)
return dobDate.getTime()?dobDate:null;
module.exports={Name,Email,Dob};
slip3.js
const http=require('http');
const qs=require('querystring');
const {Name,Email,Dob}=require('./validate1');
http.createServer((req,res)=>
if(req.method=='GET'&&req.url=='/register')
res.writeHead(200,{'Content-Type':'text/html'});
res.end(`
Name:
Email:
Date Of Birth:
Age:
Address:
<button type="submit">Register</button>
</form>
`);
else if(req.method=='POST'&&req.url=='/register')
{
let body='';
req.on('data',(data)=>
body=body+data;
});
req.on('end',()=>
const Data=qs.parse(body);
const name=Data.name;
const email=Data.email;
const dob=Data.bdate;
const age=Data.age;
const add=Data.add;
if(!Name(name))
return;
if(!Dob(dob))
return;
if(!Email(email))
return;
console.log(`Student Registered:
Name:${name}
Email:${email}
Date of Birth:${dob}
Age:${age}
Address:${add}
`);
});
else
res.writeHead(404,{'Content-Type':'text/plain'});
res.end('Not Found');
}).listen(3032);
console.log("Successfully Run.");
SLIP 4
Q.1
a)
#include<iostream.h>
class workerInfo{
char wname[50];
int no_of_hours_worked,salary;
public:
void accept(){
cin>>wname;
cin>>no_of_hours_worked;
void display(){
cout<<”Worker details”<<endl;
cout<<”Name:”<<wname<<endl;
cout<<”Salary:”<<calSal(no_of_hours_worked)<<endl;
}
int calSal(int work_hrs, int pay_rate=100){
return (work_hrs*pay_rate);
};
int main(){
workerInfo w;
w.accept();
w.display();
return 0;
b)
Q.2
a)
name.js
function flname(first,last){
function age(dob){
let age=current.getFullYear()-bdate.getFullYear();
if(current<bdate){
age--;
return age;
module.exports={flname,age};
slip4.js
let app=require("./name");
const readline=require('readline');
const rl=readline.createInterface({
input:process.stdin,
output:process.stdout
});
});
});
});
b)
SLIP 5
Q.1
a)
#include<iostream.h>
class point{
int x,y;
public:
x=a;
y=b;
void showpoint(){
cout<<”(”<<x<<”,”<<y<<”)”;
};
int main(){
int a,b;
point p;
cout<<”Enter coordinates”<<endl;
cout<<”Enter x:”;
cin>>a;
cout<<”Enter y:”;
cin>>b;
p.setpoint(a,b);
p.showpoint();
return 0;
b)
#include<iostream.h>
class Shape
public:
};
private:
double radius;
public:
Circle(double r):radius(r){}
return PI*radius*radius;
};
private:
double radius;
public:
Sphere(double r):radius(r){}
return 4*PI*radius*radius;
};
private:
double radius;
double height;
public:
return 2*PI*radius*(radius+height);
};
int main()
Circle c1(5);
Sphere s1(3);
Cylinder cy1(4,6);
cout<<”Area of Circle:”<<c1.area()<<endl;
cout<<”Area of Sphere:”<<s1.area()<<endl;
cout<<”Area of Cylinder:”<<cy1.area()<<endl;
return 0;
Q.2
a)
const buf1=Buffer.from('Hello ');
const buf2=Buffer.from('Nashik');
console.log('Concatenated Buffer:',concat.toString());
const compare=buf1.compare(buf2);
console.log('Comparison Buffer:',compare);
const copy=Buffer.from(buf2);
console.log('Copied Buffer:',copy.toString());
b)
let mysql=require(‘mysql’);
let con=mysql.createConnection({
host: “localhost”,
user: “root”,
password: “12345”,
port: “3306”,
database: “college”
});
con.connection((err) => {
if(err){
console.log(err);
}else{
console.log(“Connected Successfully”);
});
if(err){
console.log(err);
}else{
console.log(“CID NAME”);
console.log(“--------------------”);
Object.keys(rs).forEach((ft) => {
console.log(rs[ft].cid, “|”, rs[ft].cname);
});
});
if(err){
console.log(err);
}else{
});
con.end();
SLIP 6
Q.1
a)
#include<iostream.h>
class square{
public:
int s;
void getdata(){
cin>>s;
int calArea(){
return (s*s);
};
class rectangle{
public:
int l,w;
void getdata(){
cout<<”Enter the length of the rectangle:”;
cin>>l;
cin>>w;
int calArea(){
return (l*w);
};
}else{
int main(){
int s_area,r_area;
square s1;
rectangle r1;
s1.getdata();
s_area=s1.calArea();
r1.getdata();
r_area=r1.calArea();
cout<<”Square:”<<s_area<<endl;
cout<<”Rectangle:”<<r_area<<endl;
compare(s_area, r_area);
return 0;
b)
#include<iostream.h>
class Matrix
private:
int **p;
int r,c;
public:
p=new int*[r];
for(int i=0;i<r;i++)
p[i]=new int[c];
~Matrix()
for(int i=0;i<r;i++)
delete[] p[i];
delete[] p;
void acceptElements()
for(int i=0;i<r;i++)
for(j=0;j<c;j++)
cin>>p[i][j];
}
}
cout<<”Matrix elements:”<<endl;
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
cout<<p[i][j]<<””;
cout<<endl;
Matrix transposed(c,r);
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
transposed.p[j][i]=p[i][j];
return transposed;
};
int main()
cin>>rows;
cin>>cols;
Matrix mat(rows,cols);
mat.acceptElements();
cout<<”Original matrix:”<<endl;
mat.displayElements();
Matrix transposed=mat.transpose();
transposed.displayElements();
return 0;
Q.2
a)
demo_server.js
var http=require(‘http’);
var url=require(‘url’);
var fs=require(‘fs’);
http.createServer(function(req,res) {
var q=url.parse(req.url,true);
var filename=”sample.txt”+q.pathname;
fs.readFile(filename,function(err,data){
if(err){
res.writeHead(404,{‘Content-Type’:’text/html’});
res.writeHead(200,{‘Content-Type’:’text/html’});
res.write(data);
return res.end();
});
}).listen(8080);
b)
let mysql=require(‘mysql’);
let con=mysql.createConnection({
host: “localhost”,
user: “root”,
password: “12345”,
database: “college”,
port: “3306”
});
con.connect((err) => {
if(err){
console.log(err);
}else{
console.log(“Connected”);
}):
let sql=”(14,’Soham’,’SYBBA(CA)’),(15,’Sujal’,’SYBBA(CA)’),(16,’Aditya’,’SYBBA(CA)’)”;
if(err){
console.log(err);
}else{
console.log(“Warning count”,result.serverStatus);
console.log(“Messages:”,result.message);
});
con.end();
SLIP 7
Q.1
a)
#include<iostream.h>
#include<string.h>
class String
{
private:
char str[50];
public:
strncpy(str,input,49);
str[49]=’\0’;
int count=0;
for(size_t i=0;i<strlen(str);i++)
if(str[i]==ch1)
str[i]==ch2;
count++;
return count;
return str;
};
int main()
String s1(“Hello,World!”);
cout<<”Original string:”<<s1.getString()<<endl;
int replacements=s1.replace(‘o’);
cout<<”Modified string:”<<s1.getString()<<endl;
cout<<”Number of replacements:”<<replacements<<endl;
return 0;
b)
#include<iostream.h>
class Vector
private:
int size;
int* ptr;
public:
for(int i=0;i<size;i++)
ptr[i]=other.ptr[i];
~Vector()
delete[] ptr;
void acceptVector()
for(int i=0;i<size;i++)
cin>>ptr[i];
void displayVector()
{
cout<<”(“;
for(int i=0;i<size;i++)
cout<<ptr[i];
if(i<size-1)
cout<<”,”;
cout<<”)\n”;
int newSize=size+other.size;
Vector result(newSize);
int index=0;
for(int i=0;i<size;i++)
result.ptr[index++]=ptr[i];
for(i=0;i<other.size;i++)
result.ptr[index++]=other.ptr[i];
return result;
};
int main()
Vector vec1(3);
Vector vec2(2);
vec1.acceptVector();
cout<<”Enter elements for vector 2:\n”;
vec2.acceptVector();
cout<<”Vector 1:”;
vec1.displayVector();
cout<<”Vector 2:”;
vec2.displayVector();
Vector unionVector=vec1.calculateUnion(vec2);
unionVector.displayVector();
return 0;
Q.2
a)
var fs=require(‘fs’);
fs.appendFile(‘f1.txt’,’f2.txt’,function(err){
console.log(‘Updated’);
});
f1.txt
“Welcome to SY
f2.txt
BBA(CA) Department”
b)
let mysql=require(‘mysql’);
let con=mysql.createConnection({
host: “localhost”,
user: “root”,
password: “12345”,
database: “college”
});
con.connect((err) => {
if(err) throw err;
console.log(“Connected”);
});
if(err){
console.log(err);
}else{
console.log(result);
});
con.end();
SLIP 9
Q.1
a)
#include<iostream.h>
#include<conio.h>
class person{
char name[20];
char addr[20];
float sal,tax;
public:
void get(){
cin>>name>>addr>>sal;
void put(){
cout<<”Person Information:\n”;
cout<<”Name\tAddress\tSalary\tTax:\n”;
cout<<”=================================\n”;
cout<<name<<”\t”<<addr<<”\t”<<sal<<”\t”<<tax<<endl;
}
void cal_tax(){
if(sal<=20000){
tax=0;
}else if(sal>=20000||sal<=40000){
tax=(sal*5)/100;
}else{
tax=(sal*10)/100;
};
void main(){
person p;
clrscr();
p.get();
p.cal_tax();
p.put();
getch();
b)
#include<iostream.h>
#include<iomanip.h>
class Time
private:
int hours;
int minutes;
int seconds;
public:
void acceptTime()
cout<<”Enter hours:”;
cin>>hours;
cout<<”Enter minutes:”;
cin>>minutes;
cout<<”Enter seconds:”;
cin>>seconds;
void displayTime()
cout<<setw(2)<<setfill(‘0’)<<hours<<”:”<<setw(2)<<setfill(‘0’)<<minutes<<”:”<<setw(2)<<setfill(‘0’)<<seconds<
<endl;
int totalseconds1=t1.hours*3600+t1.minutes*60+t1.seconds;
int totalseconds2=t2.hours*3600+t2.minutes*60+t2.seconds;
int diffSeconds=totalSeconds2-totalSeconds1;
int diffHours=diffSeconds/3600;
diffSeconds %=3600;
int diffMinutes=diffSeconds/60;
diffSeconds %=60;
cout<<”Difference:”<<setw(2)<<setfill(‘0’)<<diffHours<<”:”<<setw(2)<<setfill(‘0’)<<diffMinutes<<”:”<<setw(2)<
<setfill(‘0’)<<diffSeconds<<endl;
};
int main()
time1.acceptTime();
time2.acceptTime();
cout<<”Time 1:”;
time1.displayTime();
cout<<”Time 2:”;
time2.displayTime();
time1.difference(time1, time2);
return 0;
Q.2
a)
var http=require(‘http’);
http.createServer(function(req,res){
res.writeHead(200,{‘Content-Type’:’text/html’});
res.write(‘<input type=”submit”>’);
res.write(‘</form>’);
return res.end();
}).listen(3000);
b)
SLIP 10
Q.1
a)
#include<iostream.h>
class Account
private:
int Acc_number;
char Acc_type;
double Balance;
public:
void acceptDetails()
cin>>Acc_number;
cin>>Acc_type;
cout<<”Enter Balance:”;
cin>>Balance;
void displayDetails()
cout<<”Account Number:”<<Acc_number<<endl;
cout<<”Account Type:”<<Acc_type<<endl;
cout<<”Balance:”<<Balance<<endl;
};
int main()
int n;
cin>>n;
for(int i=o;i<n;i++)
accounts[i].acceptDetails();
for(i=0;i<n;i++)
accounts[i].displayDetails();
cout<<endl;
}
delete[] accounts;
return 0;
b)
Q.2
a)
const http=require(‘http’);
const fs=require(‘fs’);
const path=require(‘path’);
if(req.url===’/download’){
const filePath=path.join(__dirname,’image.jpg’);
const stat=fs.statSync(filePath);
res.writeHead(200,{‘Content-Type’:’image/jpeg’,’Content-Length’:stat.size,’Content-
Disposition’:’attachment;filename=image.jpg’});
const readStream=fs.createReadStream(filePath);
readStream.pipe(res);
}else{
res.writeHead(404,{‘Content-Type’:’text/html’});
});
const PORT=process.env.PORT||3000;
server.listen(PORT, () => {
});
b)
SLIP 11
Q.1
a)
#include<iostream.h>
class MyArray{
private:
int* arr;
int size;
public:
MyArray(int s){
size=s;
arr=new int[size];
~MyArray(){
delete[] arr;
void acceptElements(){
cout<<”Enter”<<size<<”array elements:”<<endl;
for(int i=0;i<size;i++){
cin>>arr[i];
void displayElements(){
cout<<”Array elements:”;
for(int i=0;i<size;i++){
cout<<arr[i]<<” “;
cout<<endl;
void displaySum(){
int sum=0;
for(int i=0;i<size;i++){
sum+=arr[i];
}
};
int main(){
int size;
cin>>size;
MyArray myArray(size);
myArray.acceptElements();
myArray.displayElements();
myArray.displaySum();
return 0;
b)
#include<iostream.h>
class Student
protected:
int Roll_No;
char Name[50];
public:
void acceptInfo()
cin>>Roll_No;
cout<<”Enter Name:”;
cin>>Name;
void displayInfo()
cout<<”Roll No:”<<Roll_No<<endl;
cout<<”Name:”<<Name<<endl;
};
protected:
int M1,M2,M3,M4;
public:
void acceptTheoryMarks()
cin>>M1>>M2>>M3>>M4;
protected:
int P1,P2,;
public:
void acceptPracticalMarks()
cin>>P1>>P2;
private:
int Total_Marks;
float Percentage;
char Grade;
public:
void calculateResult()
{
Total_Marks=M1+M2+M3+M4+P1+P2;
Percentage=(Total_Marks)/6;
Grade=’A’;
Grade=’B’;
Grade=’C’;
Grade=’D’;
}else{
Grade=’F’;
void displayResult()
cout<<”Total Marks:”<<Total_Marks<<endl;
cout<<”Percentage:”<<Percentage<<”%”<<endl;
cout<<”Grade:”<<Grade<<endl;
};
int main()
Result r1;
int choice;
do{
cout<<”\nMenu:\n”;
cout<<”3.Calculate Result:\n”;
cout<<”4.Exit:\n”;
switch(choice){
case 1:r1.acceptInfo();
r1.acceptTheoryMarks();
r1.acceptPracticalMarks();
break;
case 2:r1.displayInfo();
break;
case 3:r1.calculateResult();
r1.displayResult();
break;
break;
}while(choice!=4);
return 0;
Q.2
a)
const http=require(‘http’);
const collegeInfo={
phone: “0253-5454666”,
website: http://www.example.com
};
const server=http.createServer((req,res) {
res.writeHead(200,{‘Content-Type’:’text/html’});
res.write(‘<h1>College Information</h1>’);
res.write(‘<p><strong>Name:</strong>’+collegeInfo.name+’</p>’);
res.write(‘<p><strong>Address:</strong>’+collegeInfo.address+’</p>’);
res.write(‘<p><strong>Phone:</strong>’+collegeInfo.phone+’</p>’);
res.write(‘<p><strong>Website:</strong> <a
href=”’+collegeInfo.website+’”>’+collegeInfo.website+’</a></p>’);
res.end();
});
const port=3100;
server.listen(port, () => {
});
b)
const express=require('express');
const app=express();
app.get('/',(req,res)=>
res.send(`
<ul>
<li><a href="/Courses">Courses</a></li>
<li><a href="/Faculty">Faculty</a></li>
<li><a href="/Contact">Contact</a></li>
</ul>
`);
});
app.get('/Courses',(req,res)=>
<ul>
<li>Advanced ML Techniques</li>
<li>Data Mining</li>
<li>AI Basics</li>
</ul>`
);
});
app.get('/Faculty',(req, res)=>
<h1>Member 1</h1>
<ul>
<li>Name:Sujal Vora</li>
<li>Designation:Professor</li>
<li>Specialization:Machine Learning</li>
</ul>
<h1>Member 2</h1>
<ul>
<li>Name:Soham Phansalkar</li>
<li>Designation:Associate Professor</li>
<li>Specialization:Data Science</li>
</ul>
<h1>Member 3</h1>
<ul>
<li>Name:Aadityakumar Singh</li>
<li>Designation:Assistant Professor</li>
<li>Specialization:Artificial Intelligence</li>
</ul>`
);
});
app.get('/Contact',(req,res)=>
res.send(`
<h2>Contact Us</h2>
<ul>
<li>Phone:997812xxxx</li>
<li>Email:sujalvora17@gmail.com</li>
<li>Address:Nashik</li>
</ul>
<ul>
<li>Phone:908923xxxx</li>
<li>Email:sohamphansalkar11@gmail.com</li>
<li>Address:Nashik</li>
</ul>
<ul>
<li>Phone:897182xxxx</li>
<li>Email:adityakumarsingh9@gmail.com</li>
<li>Address:Nashik</li>
</ul>
`);
});
app.listen(3000);
console.log("Successfully Run!");
SLIP 12
Q.1
a)
#include<iostream.h>
class Date
private:
int day;
int month;
int year;
public:
Date()
day=1;
month=1;
year=2000;
day=d;
month=m;
year=y;
void displayDate()
const char*
months[]={“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Sep”,”Oct”,”Nov”,”Dec”};
cout<<day<<”-“<<months[month-1]<<”-“<<year<<endl;
};
int main()
Date defaultDate;
cout<<”Default Date:”;
defaultDate.displayDate();
Date customDate(4,1,2021);
cout<<”Custom Date:”;
customDate.displayDate();
return 0;
b)
Q.2
a)
const EventEmitter=require(‘events’);
console.log(‘Listener 1 executed’);
};
};
myEmitter.on(‘myEvent’, listener1);
myEmitter.on(‘myEvent’, listener2);
myEmitter.emit(‘myEvent’);
b)
validate5.js
function Username(name) {
return name.match(/^[A-Za-z]+$/)!=null;
function Dob(dob) {
return dobDate.getTime()?dobDate:null;
function Email(email) {
return email.includes(‘@’)&&email.includes(‘.’);
function Mobile(mno) {
return mno.match(/^d{10}$/);
module.exports={Username,Dob,Email,Mobile};
slip12.js
const http=require('http');
const qs=require('querystring');
const {Username,Dob,Email,Mobile}=require('./validate5');
http.createServer((req,res)=>
if(req.method=='GET'&&req.url=='/register')
res.writeHead(200,{'Content-Type':'text/html'});
res.end(`
<form method="post" action="/register">
Username:
Password:
Email:
Mobile Number:
Date Of Birth:
Age:
Address:
</form>
`);
else if(req.method=='POST'&&req.url=='/register')
let body='';
req.on('data',(data)=>
body=body+data;
});
req.on('end',()=>
const Data=qs.parse(body);
const name=Data.name;
const pass=Data.pass;
const email=Data.email;
const mno=Data.mno;
const dob=Data.bdate;
const age=Data.age;
const add=Data.add;
if(!Username(name))
return;
if(!Dob(dob))
return;
if(!Email(email))
return;
if(!Mobile(mno))
console.log(`User Registered:
Username:${name}
Password:${pass}
Email:${email}
Mobile Number:${mno}
Date of Birth:${dob}
Age:${age}
Address:${add}
`);
else
res.writeHead(404,{'Content-Type':'text/plain'});
res.end('Not Found');
}).listen(3080);
console.log("Successfully Run.");
SLIP 13
Q.1
a)
#include<iostream.h>
#include<string.h>
class Product
private:
int Product_id;
char Product_Name[50];
int Qty;
double Price;
public:
Product()
Product_id=0;
Qty=0;
Price=0.0;
numObjects++;
{
Product_id=id;
Qty=qty;
Price=price;
strcpy(Product_Name,name);
numObjects++;
~Product()
numObjects--;
void acceptProductInfo()
cin>>Product_id;
cin>>Product_Name;
cout<<”Enter Quantity:”;
cin>>Qty;
cout<<”Enter Price:”;
cin>>Price;
void displayProductInfo()
cout<<”Product ID:”<<Product_id<<endl;
cout<<”Product Name:”<<Product_Name<<endl;
cout<<”Quantity:”<<Qty<<endl;
cout<<”Price:”<<Price<<endl;
};
int Product::numObjects=0;
int main()
Product::displayNumObjects();
Product p1(1,”Laptop”,5,800.0);
cout<<”\nProduct 1 Info:”<<endl;
p1.displayProductInfo();
Product:: displayNumObjects();
Product p2;
cout<<”\nProduct 2 Info:”<<endl;
p2.acceptProductInfo();
p2.displayProductInfo();
Product:: displayNumObjects();
return 0;
b)
#include<iostream.h>
class Cuboid
private:
float length;
float breadth;
float height;
public:
length=l;
breadth=b;
height=h;
void getvalues()
{
cout<<”Length:”<<length<<endl;
cout<<”Breadth:”<<breadth<<endl;
cout<<”Height:”<<height<<endl;
float volume()
return length*breadth*height;
float surfaceArea()
return 2*(length*breadth+breadth*height+height*length);
};
int main()
Cuboid c;
c.setvalues(5.0,3.0,2.0);
cout<<”Cuboid dimensions:”<<endl;
c.getvalues();
cout<<”Volume:”<<c.volume()<<endl;
cout<<”Surface Area:”<<c.surfaceArea<<endl;
return 0;
Q.2
a)
rectangle.js
class Rectangle{
constructor(length, width){
this.length=length;
this.width=width;
calculateArea(){
return this.length * this.width;
};
module exports=rectangle;
app.js
const Rectangle=require(‘./rectangle’);
const area=rectangle.calculateArea();
console.log(‘Rectangle Details:’);
console.log(‘Length:’,rectangle.length);
console.log(‘Width:’,rectangle.width);
console.log(‘Area:’,area);
b)
let mysql=require(‘mysql’);
let con=mysql.createConnection({
host: “localhost”,
user: “root”,
password: “12345”,
database: “college”,
port: “3306”,
});
con.connect((err) => {
console.log(“Connected”);
});
if(err){
console.log(err);
}else{
console.log(“Messages:”,result.message);
}
});
con.end();
SLIP 14
Q.1
a)
#include<iostream.h>
class Circle{
private:
float radius;
public:
radius=r;
return 2 * radius;
};
int main();
Circle c2;
float radius;
cin>>radius;
c2.setRadius(radius);
return 0;
b)
Q.2
a)
var fs=require('fs');
function searchWordInFile(filePath,word){
fs.readFile(filePath,'utf8',(err,data)=>{
if(err){
return;
const matches=data.match(regex);
if(matches){
}else{
});
const filePath='sample.txt';
const wordToSearch='Good';
searchWordInFile(filePath,wordToSearch);
b)
b5.js
function Bill(units)
const rate=0.50;
const Amt=units*rate;
return Amt;
module.exports={Bill};
slip14b.js
let app=require("./b5");
let prompt=require("prompt-sync")();
console.log("Electricity Bill:",app.Bill(unit));
SLIP 16
Q.1
a)
b)
#include<iostream.h>
class Matrix{
private:
int rows;
int cols;
int** data;
public:
data=new int*[rows];
for(int i=0;i<rows;i++){
data[i]=new int[cols];
~Matrix(){
for(int i=0;i<rows;i++){
delete[] data[i];
}
delete[] data;
void acceptMatrix(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>data[i][j];
cout<<”Matrix:”<<endl;
for(int i=0;i<rows;i++){
for(j=0;j<cols;j++){
cout<<data[i][j];
cout<<endl;
for(int i=0;i<cols;i++){
for(int j=0;j<rows;j++){
transpose.data[i][j];
return tanspose;
Matrix& operator++(){
for(int i=0;i<rows;i++){
for(j=0;j<cols;j++){
++data[i][j];
}
}
return *this;
};
int main(){
int rows,cols;
cin>>rows>>cols;
Matrix matrix(rows,cols);
matrix.acceptMatrix();
cout<<”\nOriginal”;
matrix.displayMatrix();
cout<<”\nTranspose”;
transpose.displayMatrix();
matrix++;
matrix.displayMatrix();
return 0;
Q.2
a)
const EventEmitter=require(‘events’);
eventEmitter.on(‘event1’, () => {
console.log(‘Event 1 occurred’);
});
eventEmitter.on(‘event2’, () => {
console.log(‘Event 2 occurred’);
});
eventEmitter.emit(‘event1’);
eventEmitter.emit(‘event2’);
console.log(‘Exiting…’);
}else{
});
b)
var mysql=require('mysql');
var con=mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
database: "employeedb",
port: "3306"
});
con.connect(function(err){
con.query(sql,function(err,result,display){
});
console.log(result);
});
});
SLIP 19
Q.1
a)
#include<iostream.h>
class Distance{
private:
int meter;
int centimeter;
public:
return *this;
}else{
return d;
cout<<”Meter:”<<meter<<”Centimeter:”<<centimeter<<endl;
};
int main(){
Distance largerDistance=d1.Larger(d2);
largerDistances.display();
return 0;
b)
Q.2
a)
const fs=require(‘fs’);
function showStartupInfo(){
function openFile(filePath){
if(err){
}else{
});
function main(){
showStartupInfo();
const filePath=’example.txt’;
openFile(filePath);
main();
b)
SLIP 20
Q.1
a)
#include<iostream.h>
class Number{
private:
int num;
public:
Number& operator++() {
++num;
return *this;
Number operator++(int) {
++(*this);
return temp;
void display() {
cout<<”Number:”<<num<<endl;;
};
int main(){
Number numObj(5);
cout<<”Original value:”<<numObj.display()<<endl;
++numObj;
cout<<”After pre-increment:”<<numObj.display()<<endl;
numObj++;
cout<<”After post-increment:”<<numObj.display()<<endl;
return 0;
b)
Q.2
a)
const fs=require(‘fs’);
const EventEmitter=require(‘events’);
fs.readFile(filename,’utf8’,(err,data) => {
if(err){
this.emit(‘error’,err);
}else{
this.emit(‘fileRead’,data);
});
fileHandler.on(‘fileRead’,(data) => {
console.log(‘File Contents:’);
console.log(data);
});
fileHandler.on(‘error’,(err) => {
});
const filename=’example.txt’;
fileHandler.readFileContents(filename);
b)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h2>First Semester</h2>
<ul>
<li>Digital Marketing</li>
<li>Data Structure</li>
<li>Software Engineering</li>
<li>Big Data</li>
<li>Angular JS</li>
</ul>
<h2>Second Semester</h2>
<ul>
<li>Networking</li>
<li>Operating System</li>
<li>Node JS</li>
</ul>
</body>
</html>
slip20b.js
const express=require('express');
const app=express();
const port=3030;
app.get('/',(req,res)=>{
res.sendFile(__dirname+'/index.html');
});
app.listen(port,()=>{
});
SLIP 22
Q.1
a)
b)
Q.2
a)
const fs=require(‘fs’);
function countLines(filePath) {
try {
const lines=fileContent.split(‘\n’);
return lines.length;
}catch(err){
return -1;
const filePath=’sample.txt’;
const lineCount=countLines(filePath);
}else{
b)
SLIP 23
Q.1
a)
#include<iostream.h>
#include<string.h>
class Mystring {
private:
char *str;
public:
str=new char[strlen(s)+1];
strcpy(str,s);
~Mystring() {
delete[] str;
cout<<endl<<str;
strcpy(temp,str);
strcat(temp,other.str);
MyString result(temp);
delete[] temp;
return result;
};
int main() {
MyString str1(“Hello”);
MyString str2(“World!”);
cout<<”String 1:”;
str1.display();
cout<<endl;
cout<<”String 2:”;
str2.display();
cout<<endl;
MyString concatenatedStr=str1+str2;
cout<<”Concatenated String:”;
concatenatedStr.display();
cout<<endl;
return 0;
b)
Q.2
a)
const fs=require(‘fs’);
if(err) {
return;
if(err) => {
return;
});
});
const filename=’sample.txt’;
const searchWord=’SYBBA(CA)’;
const replaceWord=’TYBBA(CA)’;
eTicket.js
const PDFDocument=require('pdfkit');
const fs=require('fs');
function generateETicket(ticketDetails){
const stream=fs.createWriteStream('eticket.pdf');
doc.pipe(stream);
doc.fontSize(18).text('Railway eTicket',{align:'center'});
doc.moveDown();
doc.fontSize(12).text(`Name:${ticketDetails.name}`);
doc.text(`Train No:${ticketDetails.trainNo}`);
doc.text(`From:${ticketDetails.from}`);
doc.text(`To:${ticketDetails.to}`);
doc.text(`Date:${ticketDetails.date}`);
doc.text(`Class:${ticketDetails.class}`);
doc.text(`Seat No:${ticketDetails.seatNo}`);
doc.end();
module.exports=generateETicket;
slip23b.js
const generateETicket=require('./eTicket');
const ticketDetails={
trainNo: '12345',
from: 'Mumbai',
to: 'Pune',
date: '2024-04-02',
class: 'Sleeper',
seatNo: 'A1'
};
generateETicket(ticketDetails);
SLIP 26
Q.1
a)
#include<iostream.h>
return (num1+num2+num3)/3;
return (num1+num2+num3)/3;
int main()
int int1=10,int2=20,int3=30;
float float1=10,float2=20,float3=30;
return 0;
b)
Q.2
a)
const EventEmitter=require('events');
constructor(){
super();
raiseEvent(){
setTimeout(()=>{
},2000);
myEmitter.on('customEvent',(message)=>{
console.log('Received message:',message);
});
myEmitter.raiseEvent();
b)
const express=require('express');
const app=express();
app.get('/',(req,res)=>{
res.send(`
<ul>
<li><a href="/products">Products</a></li>
<li><a href="/departments">Departments</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
`);
});
app.get('/products',(req,res)=>
res.send(`<h2>List Of Products</h2>
<ul>
<li>Electronics</li>
<li>Cloths</li>
<li>Groceries</li>
</ul>`);
});
app.get('/departments',(req,res)=>
res.send(`<h2>List Of Departments</h2>
<ul>
<li>Electronics</li>
<li>Clothing</li>
<li>Groceries</li>
</ul>`);
});
app.get('/contact',(req,res)=>
res.send(`<h2>Contact Us</h2>
<ul>
<li>Phone:892178xxxx</li>
<li>Email:dstore71@gmail.com</li>
<li>Address:Pune</li>
</ul>`);
});
app.listen(5000);
console.log("Successfully Run!");
SLIP 27
Q.1
a)
#include<iostream.h>
#include<string.h>
class College
private:
int College_id;
char College_Name[MAX_LENGTH];
int Establishment_year;
char University_Name[MAX_LENGTH];
public:
in>>college.College_id;
in.ignore();
in.getline(college.College_Name,MAX_LENGTH);
cout<<”Establishment Year:”;
in>>college.Establishment_year;
in.ignore();
in.getline(college.University_Name,MAX_LENGTH);
return in;
out<<”College ID:”<<college.College_id<<endl;
out<<”College Name:”<<college.College_Name<<endl;
out<<”Establishment Year:”<<college.Establishment_year<<endl;
out<<”University Name:”<<college.University_Name<<endl;
return out;
};
int main()
College college;
cin>>college;
cout<<”College Information:”<<endl;
cout<<college;
return 0;
}
b)
Q.2
a)
const fs=require('fs');
const path=require('path');
const directoryName='example_directory';
fs.mkdir(directoryName,(err)=>{
if(err){
}else{
const filePath=path.join(__dirname,directoryName,'example_file.txt');
fs.writeFile(filePath,fileContents,(err)=>{
if(err){
}else{
});
});
b)
validate4.js
function Name(name)
return name.match(/^[A-Za-z]+$/)!=null;
function Dob(dob)
{
return dobDate.getTime()?dobDate:null;
function Email(email)
return email.includes('@')&&email.includes('.');
function Mobile(mno)
return mno.match(/^\d{10}$/);
module.exports={Name,Dob,Email,Mobile};
slip27b.js
const http=require('http');
const qs=require('querystring');
const {Name,Email,Mobile}=require('./validate4');
http.createServer((req,res)=>
if(req.method=='GET'&&req.url=='/register')
res.writeHead(200,{'Content-Type':'text/html'});
res.end(`
Name:
Email:
Mobile Number:
Date Of Birth:
Age:
<input type="number" id="age" name="age"><br>
Address:
<button type="submit">Register</button>
</form>
`);
else if(req.method=='POST'&&req.url=='/register')
let body='';
req.on('data',(data)=>
body=body+data;
});
req.on('end',()=>
const Data=qs.parse(body);
const name=Data.name;
const email=Data.email;
const mno=Data.mno;
const dob=Data.bdate;
const age=Data.age;
const add=Data.add;
if(!Name(name))
return;
if(!Email(email))
return;
}
if(!Mobile(mno))
console.log(`Student Registered:
Name:${name}
Email:${email}
Mobile Number:${mno}
Date of Birth:${dob}
Age:${age}
Address:${add}
`);
});
else
res.writeHead(404,{'Content-Type':'text/plain'});
res.end('Not Found');
}).listen(3037);
console.log("Successfully Run.");
SLIP 29
Q.1
a)
b)
Q.2
a)
rectangle.js
class rectangle{
constructor(length,width){
this.length=length;
this.width=width;
calculateArea(){
return this.length*this.width;
};
module.exports=rectangle;
app.js
const area=rectangle.calculateArea();
console.log('Rectangle Details:');
console.log('Length:',rectangle.lenth);
console.log('Width:',rectangle.width);
console.log('Area:',area);
b)
SLIP 30
Q.1
a)
#include<iostream.h>
class Integer_Array;
class Float_Array;
class Integer_Array
private:
int size;
int arr[MAX_SIZE];
public:
Integer_Array(int s):size(s) {}
void accept()
cout<<”Enter”<<size<<”intger elements:”<<endl;
for(int i=0;i<size;i++)
cin>>arr[i];
for(int i=0;i<size;i++)
cout<<arr[i]<<””;
cout<<endl;
};
class Float_Array
private:
int size;
int arr[MAX_SIZE];
public:
Integer_Array(int s):size(s) {}
void accept()
cout<<”Enter”<<size<<”float elements:”<<endl;
for(int i=0;i<size;i++)
{
cin>>arr[i];
for(int i=0;i<size;i++)
cout<<arr[i]<<””;
cout<<endl;
};
int sum=0;
for(int i=0;i<intArray.size;i++)
sum+=intArray.arr[i];
return (sum)/intArray.size;
float sum=0;
for(int i=0;i<floatArray.size;i++)
sum+=floatArray.arr[i];
return (sum)/floatArray.size;
}
int main()
int intSize,floatSize;
cin>>intSize;
Integer_Array intArray(intSize);
intArray.accept();
intArray.display();
cin>>floatSize;
Float_Array floatArray(floatSize);
floatArray.accept();
floatArray.display();
return 0;
b)
Q.2
a)
circle.js
const PIE=3.14;
function area(r){
return PIE*r*r;
};
function circum(r){
return 2*PIE*r;
};
module.exports={area,circum};
app.js
let app=require("./circle");
const readline=require('readline');
const rl=readline.createInterface({
input:process.stdin,
output:process.stdout
});
rl.question('Enter a radius:',(r)=>{
});
b)
slip30DB.js
let mysql=require("mysql");
let con=mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
port: "3306",
});
con.connect(function(err){
if (err) {
console.log(err);
} else {
console.log("connected");
});
console.log("Database Created");
});
Slip30b.js
let mysql=require("mysql");
let con=mysql.createConnection({
host: "localhost",
user: "root",
password: "12345",
port: "3306",
database: "hospitalDB"
});
con.connect(function(err){
if (err) {
console.log(err);
} else {
console.log("connected");
});
con.query(sql,function(err,result){
console.log("Table Created");
});