C++ FILE
C++ FILE
#include<iostream>
int main(){
return 0;
2.
#include<iostream>
int main(){
int a = 5;
int b = 6;
return 0;
}
3.
#include<iostream>
int main(){
int a = 5;
int b = 10;
int c = 12;
return 0;
4.
#include<iostream>
int main(){
float a = 5;
float b = 10;
float c = 12;
float d = 13;
float e = 2;
return 0;
5.
#include<iostream>
int main(){
int a,b,c,d,e;
cout<<"enter a : "<<endl;
cin>>a;
cout<<"enter b : "<<endl;
cin>>b;
cout<<"enter c : "<<endl;
cin>>c;
cout<<"enter d : "<<endl;
cin>>d;
cout<<"enter e : "<<endl;
cin>>e;
cout<<"sum is : "<<sum<<endl;
return 0;
}
6.
#include<iostream>
int main() {
cout << "Total Marks: " << sum << "/500" << endl;
cout << "Percentage is: " << percentage << "%" << endl;
return 0;
}
7.
#include<iostream>
int main() {
return 0;
8.
#include<iostream>
#include<cmath>
int main() {
float base, height, length, breadth, radius;
return 0;
1.
#include<iostream>
class Employee {
public:
void input() {
cout << "Enter Basic Salary: ";
void calculate() {
void display() {
};
int main() {
Employee emp;
emp.input();
emp.calculate();
emp.display();
return 0;
}
2.
#include<iostream>
class Student {
string name;
int roll;
float marks;
public:
void input() {
getline(cin, name);
void display() {
};
int main() {
Student s;
s.input();
s.display();
return 0;
}
3. #include <iostream>
class Student {
private:
string name;
int age;
public:
Student() {
name = "Unknown";
age = 0;
Student(string n, int a) {
name = n;
age = a;
Student(const Student& s) {
name = s.name;
age = s.age;
void display() {
cout << "Name: " << name << ", Age: " << age << endl;
};
int main() {
Student s1;
s1.display();
s2.display();
Student s3 = s2;
s3.display();
return 0;
4.
#include <iostream>
class Rectangle {
private:
int length;
int width;
public:
Rectangle() {
length = 0;
width = 0;
}
Rectangle(int l, int w) {
length = l;
width = w;
Rectangle(int l) {
length = l;
width = l;
void displayArea() {
};
int main() {
Rectangle r1;
r1.displayArea();
r2.displayArea();
Rectangle r3(4);
r3.displayArea();
return 0;
5.
#include <iostream>
using namespace std;
class Calculator {
public:
return a + b;
return a + b + c;
};
int main() {
Calculator calc;
return 0;
6.
#include <iostream>
class Calculator {
public:
return a + b;
return a + b;
}
return a + b;
};
int main() {
Calculator calc;
cout << "Sum of two integers: " << calc.add(5, 3) << endl;
cout << "Sum of two floats: " << calc.add(5.5f, 3.2f) << endl;
cout << "Sum of integer and float: " << calc.add(5, 3.2f) << endl;
return 0;
7.
#include <iostream>
class Calculator {
public:
return a + b;
return a + b + c;
};
int main() {
Calculator calc;
int a, b, c;
return 0;
8.
#include <iostream>
class Calculator {
public:
return a + b;
return a + b;
return a + b;
};
int main() {
Calculator calc;
cout << "Sum of two integers: " << calc.add(int1, int2) << endl;
cout << "Sum of two floats: " << calc.add(float1, float2) << endl;
cout << "Sum of integer and float: " << calc.add(int1, float1) << endl;
return 0;