print oop1
print oop1
Code:
#include<iostream>
int main(){
cout << "Size of char : " << sizeof(char) << " byte " << endl;
cout << "Size of int : " << sizeof(int) << " bytes " << endl;
cout << "Size of float : " << sizeof(float) << " bytes" << endl;
cout << "Size of double : " << sizeof(double) << " bytes " << endl;
cout << "Size of short int : " << sizeof(short int) << " bytes " << endl;
cout << "Size of long int : " << sizeof(long int) << " bytes " << endl;
return 0;
Output:
1B
Code:
#include <iostream>
int main() {
int value;
// Taking input
cout << "Decimal: " << dec << value << endl;
cout << "Hexadecimal: " << hex << value << endl;
cout << "Octal: " << oct << value << endl;
return 0;
Output:
1C
Code:
#include<iostream>
int main(){
cout << celsius << " °C is " << fahrenheit << " °F" << endl;
cout << fahrenheit << " °F is " << celsius << " °C" << endl;
return 0;
Output:
2A
Code:
#include<iostream>
int main(){
int n, sum = 0;
cin>>n;
for(int i= 1; i<=n;i++){
sum += i;
cout<<endl;
return 0;
Output:
2B
Code:
#include <iostream>
cout << "Element [" << i + 1 << "][" << j + 1 << "]: ";
int main() {
int m, n;
cin >> n;
readMatrix(m, n);
return 0;
Output:
2C
Code
#include <iostream>
int count = 0;
if (lowerCh == 'a' || lowerCh == 'e' || lowerCh == 'i' || lowerCh == 'o' || lowerCh == 'u') {
count++;
return count;
int main() {
string input;
getline(cin, input);
cout << "Number of vowels in the string: " << vowelCount << endl;
return 0;
}
Output:
3A
#include <iostream>
class SwapNumbers {
public:
{ int temp = a;
a = b;
b = temp;
cout << "After swap (Call by Value): a = " << a << ", b = " << b << endl;
{ int temp = a;
a = b;
b = temp;
cout << "After swap (Call by Reference): a = " << a << ", b = " << b << endl;
};
int main() {
int x, y;
SwapNumbers obj;
// Input values
// Call by value
obj.swapByValue(x, y);
cout << "After Call by Value in main: x = " << x << ", y = " << y << endl; // No change in main
// Call by reference
obj.swapByReference(x, y);
cout << "After Call by Reference in main: x = " << x << ", y = " << y << endl; // Swapped in main
return 0;
Output:
3B
Code:
#include <iostream>
int main() {
int number;
cout << "Square of " << number << " is: " << square(number) << endl;
cout << "Cube of " << number << " is: " << cube(number) << endl;
return 0;
}
Output:
3C
#include <iostream>
class AreaCalculator {
public:
};
int main() {
AreaCalculator calc;
cout << "Area of rectangle: " << calc.area(length, width) << endl;
// Input for triangle
cout << "Area of triangle: " << calc.area(base, height, 0) << endl;
cout << "Surface area of sphere: " << calc.area(radius) << endl;
return 0;
Output:
4A
#include <iostream>
class Student {
private:
string name;
int rollNumber;
long prn;
public:
void enterDetails() {
getline(cin, name);
void displayDetails() {
};
int main() {
Student student;
student.enterDetails();
student.displayDetails();
return 0;
Output:
4B
#include <iostream>
class Employee {
private:
string name;
public:
void inputDetails();
void calculateAllowances();
void calculateGrossSalary();
void displayDetails();
};
// Member function defined outside the class using scope resolution operator
void Employee::inputDetails() {
getline(cin, name);
}
// Member function defined outside the class using scope resolution operator
void Employee::calculateAllowances() {
// Member function defined outside the class using scope resolution operator
void Employee::calculateGrossSalary() {
// Member function defined outside the class using scope resolution operator
void Employee::displayDetails() {
int main() {
Employee emp;
emp.inputDetails();
// Calculate TA and DA
emp.calculateAllowances();
// Calculate gross salary
emp.calculateGrossSalary();
emp.displayDetails();
return 0;
Output:
4C
#include <iostream>
class DivisibleByNine {
private:
int count;
int sum;
public:
};
if (i % 9 == 0) {
obj.count++;
obj.sum += i;
cout << "Number of integers divisible by 9 between 100 and 200: " << obj.count << endl;
cout << "Sum of these integers: " << obj.sum << endl;
}
int main() {
DivisibleByNine obj;
return 0;
Output: