0% found this document useful (0 votes)
92 views6 pages

C++ Practical Exercises for B.Tech

This document contains instructions and code snippets for two C++ programming assignments. The first asks students to write a program to display a user's basic details by defining a struct containing name, address, and contact number fields. The second asks students to write programs to determine if a number is even or odd using the remainder operator, and to build a basic calculator using a switch statement to handle addition, subtraction, multiplication, and division operations on two input numbers. Students are asked to provide screenshots of the output for each program.

Uploaded by

Vraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views6 pages

C++ Practical Exercises for B.Tech

This document contains instructions and code snippets for two C++ programming assignments. The first asks students to write a program to display a user's basic details by defining a struct containing name, address, and contact number fields. The second asks students to write programs to determine if a number is even or odd using the remainder operator, and to build a basic calculator using a switch statement to handle addition, subtraction, multiplication, and division operations on two input numbers. Students are asked to provide screenshots of the output for each program.

Uploaded by

Vraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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

You might also like