Professional Documents
Culture Documents
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
1.Basic “HELLO WORLD” Program
#include <iostream>
int main() {
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
2.Basic Input Output Program
#include <iostream>
int main() {
int num;
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
3.Arithmetic Operations
#include <iostream>
int main()
num1 = 10;
num2 = 3;
cout << "num1 - num2 = " << (num1 - num2) << endl;
cout << "num1 * num2 = " << (num1 * num2) << endl;
cout << "num1 / num2 = " << (num1 / num2) << endl;
cout << "num1 % num2 = " << (num1 % num2) << endl;
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
4.User Defined Function for Printing “HELLO WORLD”
#include <iostream>
void print();
int main()
print();
return 0;
void print()
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
5.User Defined Function for Arithmetic Operations
#include<iostream>
using namespace std;
int add(int x,int y)
{
cout<<x+y<<endl;
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
6.Working of objects and class in C++ Programming
#include <iostream>
class Employee{
public:
string Name;
string Company;
int Age;
void IntroduceYourself(){
cout << "I'm " << Age << " years old";
};
int main(){
Employee employee1;
employee1.Name = "shalom";
employee1.Company = "amazon";
employee1.Age =20;
employee1.IntroduceYourself();
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
7.working of public and private in C++ Class
#include<iostream>
using namespace std;
class calculate
{
private:
int length;
int width;
int height;
public:
void data(int l, int w, int h)
{
length = l;
width = w;
height = h;
}
int Area()
{
return 2 * (length + width + height);
}
int Volume()
{
return length * width * height;
}
};
int main()
{
int l, w, h;
cout<<"Enter the Length, Width and Height: \n";
cin>>l>>w>>h;
calculate calc1;
calc1.data(l,w,h);
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
8.Demonstrate the use of static Static variables in a
Function
#include <iostream>
#include <string>
void counter()
{
// static variable
// function calls
count++;
}
int main()
{
counter();
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
9.Demonstrate static variables inside a class
#include<iostream>
class GfG
{
public:
static int i;
GfG()
{
//do nothing
};
};
int main()
{
GfG obj1;
GfG obj2;
obj1.i =4;
obj2.i = 5;
// prints value of i
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
10.Calculate the area of a wall
#include <iostream>
class Wall {
private:
double length;
double height;
public:
length = len;
height = hgt;
double calculateArea() {
};
int main() {
Wall wall1(15.4,17.3);
Wall wall2(22.5,27.1);
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
11.Calculate the average marks of two students
#include <iostream>
using namespace std;
class Student {
public:
double marks;
int main() {
Student student1(95.3), student2(88.5);
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
12.Overload ++ when used as prefix
#include <iostream>
using namespace std;
class Count {
private:
int value;
public:
void display() {
cout << "Count: " << value << endl;
}
};
int main() {
Count count1;
count1.display();
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
13.Overload ++ when used as prefix and postfix
#include <iostream>
using namespace std;
class Count {
private:
int value;
public:
void display() {
cout << "Count: " << value << endl;
}
};
int main() {
Count count1;
count1.display();
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
14.Printing Address of Variables Using Pointer
#include <iostream>
int main()
// declare variables
int num1 = 8;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
15.Printing value and Address of Variables
#include <iostream>
int main() {
int* pointNum;
pointNum = &Num;
cout << "Address of Num (&Num) = " << &Num << end;
cout << "Content of the address pointed to by pointNum (*pointNum) = " << *pointNum << endl;
return 0;
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
16.Changing Value Pointed by Pointers
#include <iostream>
using namespace std;
int main() {
int var = 15;
int* pointVar;
// print var
cout << "var = " << var << endl;
// print *pointVar
cout << "*pointVar = " << *pointVar << endl
<< endl;
// print var
cout << "var = " << var << endl;
// print *pointVar
cout << "*pointVar = " << *pointVar << endl
<< endl;
// print var
cout << "var = " << var << endl;
// print *pointVar
cout << "*pointVar = " << *pointVar << endl;
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
17.Program to display address of each element of an array
#include <iostream>
using namespace std;
int main()
{
float arr[3];
// ptr = &arr[0]
ptr = arr;
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
OUTPUT
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE
18.Program to insert and display data entered by using
pointer notation
#include <iostream>
using namespace std;
int main() {
float arr[5];
return 0;
}
[Type here]
Name- Shalom Gosain
Roll no- 211486
Branch - B.Tech CSE