PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
PRACTICAL SET-1
1. WAP to display basic details of a User like Name, Address and contact details.
#include<iostream>
using namespace std;
struct student
char name[20];
char address[100];
long contact;
};
int main()
student s;
cout<<"enter information"<<endl;
cout<<"enter the name:";
cin>>s.name;
cout<<"enter the address:";
cin>>s.address;
cout<<"enter the contact number:";
cin>>s.contact;
Name: Vraj Parikh Enrollment number: 200305015132
PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
cout<<"\n displaying the information:";
cout<<"name:"<<s.name<<endl;
cout<<"address:"<<s.address<<endl;
cout<<"contact number"<<s.contact;
return 0;
OUTPUT: Paste the output screen shot
Name: Vraj Parikh Enrollment number: 200305105132
PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
PRACTICAL SET-2
1. Write a program to find whether the given number is odd or even.
#include<iostream>
using namespace std;
int main()
int number,remainder;
cout<<"enter the number:";
cin>>number;
remainder = number % 2;
if (remainder == 0)
cout<<number<<" is an even integer"<<endl;
else
cout<<number<<" is an odd integer"<<endl;
return 0;
OUTPUT: Paste the output screen shot
Name: Vraj Parikh Enrollment number: 200305105132
PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
2. Write a program to make calculator using switch statement.
#include <iostream>
using namespace std;
int main()
char op;
float a, b;
Name: Vraj Parikh Enrollment number: 200305105132
PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
cout<<"enter the airthmetic operator: +, -, *, and /: ";
cin>>op;
cout<<"enter two numbers: ";
cin>>a>>b;
switch(op)
case '+':
cout<<a<<" + "<<b<<" = "<< a + b;
break;
case '-':
cout<<a<<" - "<<b<<" = "<< a - b;
break;
case '*':
cout<<a<<" * "<<b<<" = "<<a * b;
break;
case '/':
cout<<a<<" / "<<b<<" = "<<a / b;
break;
Name: Vraj Parikh Enrollment number: 200305105132
PARUL UNIVERSITY
FACULTY OF ENGINEERING AND TECHNOLGOY
Object Oriented Programming with C++ (203105338) B. Tech. 2nd YEAR
default:
cout<<"enter operator is not correct.";
break;
return 0;
OUTPUT: Paste the output screen shot
Name: Vraj Parikh Enrollment number: 200305105132