Document (8)
Document (8)
Int main() {
Float num1, num2;
#include <iostream>
Using namespace std;
Int main() {
Int num1, num2;
Return 0;
}
3. Program to Implement Call by
Value
#include <iostream>
Using namespace std;
Int main() {
Int num1, num2;
swapNumbers(num1, num2);
cout << “After swapping in main: num1 = “ << num1 << “,
num2 = “ << num2 << endl;
return 0;
}
}
4. Program to Print a Matrix
#include <iostream>
Using namespace std;
Int main() {
Int rows, cols;
Cout << “Enter the number of rows and columns of the matrix:
“;
Cin >> rows >> cols;
Int matrix[rows][cols];
Return 0;
}
5. Program to Implement Call by
Reference
#include <iostream>
Using namespace std;
Int main() {
Int num1, num2;
swapNumbers(num1, num2);
return 0;
}
6. Program to Print the First 10
Multiples of a Given Number Using a
while Loop
#include <iostream>
Using namespace std;
Int main() {
Int num, I = 1;
Cout << “The first 10 multiples of “ << num << “ are:” << endl;
#include <iostream>
#include <string>
Using namespace std;
Int main() {
String str;
// Convert to uppercase
For (char &c : str) {
C = toupper©;
}
Cout << “String in uppercase: “ << str << endl;
Return 0;
}
}
Int main() {
Int n, pos, element;
Return 0;
}
#include <iostream>
Using namespace std;
Public:
// Default constructor
Example() {
Number = 0;
Cout << “Default constructor called. Number initialized to
0.” << endl;
}
Void display() {
Cout << “Number: “ << number << endl;
}
};
Int main() {
// Creating an object of the class
Example obj;
Return 0;
}
10.Program Using a Class to Find the
Largest Number from Given Three
Numbers
#include <iostream>
Using namespace std;
Class LargestNumber {
Int num1, num2, num3;
Public:
// Function to accept three numbers
Void inputNumbers() {
Cout << “Enter three numbers: “;
Cin >> num1 >> num2 >> num3;
}
Int main() {
LargestNumber obj;
Return 0;
}