c++
c++
return 0;
}
6.#include <iostream>
using namespace std;
int main() {
int a, b, c;
cout << "Enter three numbers: ";
cin >> a >> b >> c;
return 0;
}
7.#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number to display its multiplication table: ";
cin >> num;
return 0;
}
8.#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
continue; // Skip even numbers
}
cout << i << " ";
}
cout << endl;
return 0;
}
9.#include <iostream>
using namespace std;
int main() {
int day;
cout << "Enter a number (1-7) to get the day of the week: ";
cin >> day;
switch (day) {
case 1:
cout << "Monday" << endl;
break;
case 2:
cout << "Tuesday" << endl;
break;
case 3:
cout << "Wednesday" << endl;
break;
case 4:
cout << "Thursday" << endl;
break;
case 5:
cout << "Friday" << endl;
break;
case 6:
cout << "Saturday" << endl;
break;
case 7:
cout << "Sunday" << endl;
break;
default:
cout << "Invalid input! Please enter a number between 1 and 7." << endl;
break;
}
return 0;
}
10.#include <iostream>
using namespace std;
int factorial(int n) {
if (n <= 1) {
return 1;
}
return n * factorial(n - 1);
}
int main() {
int num;
cout << "Enter a number to calculate its factorial: ";
cin >> num;
cout << "The factorial of " << num << " is: " << factorial(num) << endl;
return 0;
}
21, #include <iostream>
using namespace std;
class Box {
private:
double length, width, height;
public:
// Default and Parameterized Constructor
Box(double l = 0, double w = 0, double h = 0) : length(l), width(w), height(h) {}
// Copy Constructor
Box(const Box &b) = default;
int main() {
double l, w, h;
return 0;
}