C Lastassignment
C Lastassignment
#include <iostream>
int main() {
std::cout << "The area of the room is: " << area << std::endl;
return 0;
2. Write a C++ program to display the remainder and quotient when one integer number is divided by
another:
#include <iostream>
int main() {
return 0;
Activity 4
#include <iostream>
#include <cmath>
int main() {
while (binaryNumber != 0) {
binaryNumber /= 10;
decimalNumber += remainder * pow(2, i);
++i;
return 0;
Activity 5
Write a C++ program for a guessing game. Let your program randomly generate a secret number
between 1 and 100. Let the program allow the user to guess the number and display YOU ARE CORRECT
if the correct number is guessed , TOO HIGH if the guessed number is higher than the secret number,
TOO LOW if the guessed umber is lower than the secret number, SORRY!! TRY AGAIN NEXT TIME if the
guess exceed three times.
#include <iostream>
#include <cstdlib>
#include <ctime>
int main() {
int secretNumber = rand() % 100 + 1; // Generate a random number between 1 and 100
std::cout << "I have picked a secret number between 1 and 100." << std::endl;
do {
attempts++;
if (guess == secretNumber) {
break;
} else {
if (attempts >= 3) {
std::cout << "SORRY!! TRY AGAIN NEXT TIME. The secret number was: " << secretNumber <<
std::endl;
break;
} while (true);
return 0;
Activity 6
Write C++ program to calculate an area of 3 rectangles of the following lengths and breaths 12,22,44
and 10,6,15 respectively
#include <iostream>
int main() {
std::cout << "The area of rectangle " << (i + 1) << " is: " << area << std::endl;
return 0;
}.
Activity 7
#include <iostream>
#include <unordered_set>
std::unordered_set<int> seen;
std::cout << "Duplicate element found: " << arr[i] << std::endl;
return;
seen.insert(arr[i]);
int main() {
findDuplicate(arr, size);
return 0;
Activity 8
#include <iostream>
int main() {
int matrix[2][2];
std::cout << "Enter the elements of the 2x2 matrix:" << std::endl;
for (int i = 0; i < 2; ++i) {
std::cout << "Enter element at position (" << i << ", " << j << "): ";
std::cout << "The determinant of the matrix is: " << determinant << std::endl;
return 0;
Activity 9
Write a C++ program to calculate the sum of the series below using function
#include <iostream>
#include <cmath>
double sum = 1.0; // Initialize the sum with the first term of the series
double term = std::pow(x, i) / std::tgamma(i + 1); // Calculate each term of the series
}
return sum;
int main() {
double x;
int n;
std::cin >> x;
std::cin >> n;
std::cout << "The sum of the series (1+X)^n is: " << seriesSum << std::endl;
return 0;
Activity 10
#include <iostream>
number /= 10;
int main() {
int number;
if (isPalindrome(number)) {
} else {
return 0;