Solution quizes
Quiz 3
#include <iostream>
using namespace std;
int main() {
int marks1, marks2;
cout << "Enter marks for user 1: ";
cin >> marks1;
cout << "Enter marks for user 2: ";
cin >> marks2;
int percentage1 = (marks1 * 100) / 100;
int percentage2 = (marks2 * 100) / 100;
if (percentage1 == 100 || percentage2 == 100) {
cout << "Excellent" << endl;
} else if (percentage1 >= 70 || percentage2 >= 70) {
cout << "Average" << endl;
} else if (percentage1 >= 50 || percentage2 >= 50) {
cout << "Pass" << endl;
} else {
cout << "Fail" << endl;
return 0;
}
Solution quizes
Quiz 4
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
char chars[3];
cout << "Enter three characters separated by spaces: ";
cin >> chars[0] >> chars[1] >> chars[2];
cout << "Enter 1 to sort in ascending order or 2 to sort in descending order: ";
int choice;
cin >> choice;
if (choice == 1) {
sort(chars, chars + 3);
} else if (choice == 2) {
sort(chars, chars + 3, greater<char>());
} else {
cout << "Invalid choice" << endl;
return 1;
cout << "Sorted characters: " << chars[0] << " " << chars[1] << " " << chars[2] << endl;
return 0;
}
Solution quizes
Quiz no y
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double base, exponent, result;
cout << "Enter base number and exponent separated by space: ";
cin >> base >> exponent;
result = pow(base, exponent);
cout << base << " raised to the power of " << exponent << " is: " << result << endl;
return 0;
Quiz no 5
#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 5; ++i) {
for (int j = 1; j <= i; ++j) {
cout << i << " ";
cout << endl;
}
Solution quizes
return 0;
Quiz no pp
#include <iostream>
using namespace std;
int main() {
int lines;
cout << "Enter number of lines to print: ";
cin >> lines;
for (int i = 1; i <= lines; ++i) {
cout << "@";
for (int j = 2; j < i; ++j) {
cout << " @";
cout << " @" << endl;
return 0;
Quiz t part a
#include <iostream>
using namespace std;
int main() {
Solution quizes
for (int i = 1; i <= 4; ++i) {
for (int j = 1; j <= i; ++j) {
cout << "*";
cout << endl;
for (int i = 3; i >= 1; --i) {
for (int j = 1; j <= i; ++j) {
cout << "*";
cout << endl;
cout << '\a'; // Generates the bell sound
return 0;
Part B
#include <iostream>
using namespace std;
int main() {
int x = 5, y = 6, z = 8;
cout << "x == 5 is " << (x == 5 ? "true" : "false") << endl;
cout << "z != 4 is " << (z != 4 ? "true" : "false") << endl;
cout << "y > 12 is " << (y > 12 ? "true" : "false") << endl;
Solution quizes
return 0;
Quiz q1
#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 5; ++i) {
for (int j = 1; j <= i; ++j) {
cout << j << " ";
cout << endl;
cout << "\a"; // Generates the bell sound
return 0;
B part
#include <iostream>
using namespace std;
int main() {
int choice;
cout << "Menu:" << endl;
cout << "1. Find the sum of numbers" << endl;
Solution quizes
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
int count, num, sum = 0;
cout << "Enter the count of numbers: ";
cin >> count;
cout << "Enter " << count << " numbers:" << endl;
for (int i = 0; i < count; ++i) {
cin >> num;
sum += num;
cout << "The sum of the numbers is: " << sum << endl;
} else {
cout << "Invalid choice" << endl;
return 0;
Quiz no oo part a
#include <iostream>
using namespace std;
int main() {
long long product = 1; // Initialize product as 1
Solution quizes
for (int i = 1; i <= 50; i += 2) { // Loop through odd numbers from 1 to 50
product *= i; // Multiply the current odd number to the product
cout << "Product of all odd numbers from 1 to 50 is: " << product << endl;
return 0;
Part b
#include <iostream>
using namespace std;
int main() {
int n, m;
long long result = 1;
cout << "Enter base number and exponent separated by space: ";
cin >> n >> m;
for (int i = 0; i < m; ++i) {
result *= n;
cout << n << " raised to the power of " << m << " is: " << result << endl;
return 0;
Quiz no q2
Solution quizes
#include <iostream>
using namespace std;
int main() {
int num1, num2;
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
int larger = (num1 > num2) ? num1 : num2;
int smaller = (num1 < num2) ? num1 : num2;
cout << "The larger number is: " << larger << endl;
cout << "The smaller number is: " << smaller << endl;
return 0;
Quiz no q3
#include <iostream>
using namespace std;
int main() {
float fahrenheit;
cout << "Enter temperature in Fahrenheit: ";
Solution quizes
cin >> fahrenheit;
float celsius = (fahrenheit - 32) * 5 / 9;
cout << "Temperature in Celsius: " << celsius << " C" << endl;
if (celsius < 0) {
cout << "Freezing Point" << endl;
} else if (celsius >= 0 && celsius <= 8) {
cout << "Fridge Temperature" << endl;
} else if (celsius == 37) {
cout << "Body Temperature" << endl;
} else if (celsius > 75 && celsius <= 100) {
cout << "Boiling Point" << endl;
return 0;
Quiz no p
#include <iostream>
#include <string>
using namespace std;
int main() {
string color1, color2;
cout << "Enter two primary colors (red, blue, or yellow): ";
cin >> color1 >> color2;
Solution quizes
if ((color1 == "red" && color2 == "blue") || (color1 == "blue" && color2 == "red")) {
cout << "Purple" << endl;
} else if ((color1 == "red" && color2 == "yellow") || (color1 == "yellow" && color2 == "red")) {
cout << "Orange" << endl;
} else if ((color1 == "blue" && color2 == "yellow") || (color1 == "yellow" && color2 == "blue")) {
cout << "Green" << endl;
} else {
cout << "Error: Invalid colors entered!" << endl;
return 0;
Quiz no q3
#include <iostream>
using namespace std;
int main() {
char employeeType;
char calculationType;
bool continueCalculation = true;
while (continueCalculation) {
cout << "Enter employee type (P for permanent, D for daily wages): ";
cin >> employeeType;
double hourlyRate;
double medicalRate;
Solution quizes
if (employeeType == 'P') {
hourlyRate = 800;
medicalRate = 0.05;
} else if (employeeType == 'D') {
hourlyRate = 400;
medicalRate = 0.03;
} else {
cout << "Invalid employee type! Please enter P or D." << endl;
continue;
cout << "Enter C for calculating salary, M for medical charges: ";
cin >> calculationType;
if (calculationType == 'C') {
int hoursWorked;
cout << "Enter number of hours worked: ";
cin >> hoursWorked;
double totalSalary = hoursWorked * hourlyRate;
double medicalCharges = totalSalary * medicalRate;
cout << "Total salary: " << totalSalary << endl;
cout << "Medical charges: " << medicalCharges << endl;
} else if (calculationType == 'M') {
double totalSalary;
cout << "Enter total salary: ";
cin >> totalSalary;
Solution quizes
double medicalCharges = totalSalary * medicalRate;
cout << "Medical charges: " << medicalCharges << endl;
} else {
cout << "Invalid calculation type! Please enter C or M." << endl;
continue;
char choice;
cout << "Do you want to continue (Y/N)? ";
cin >> choice;
if (choice != 'Y' && choice != 'y') {
continueCalculation = false;
return 0;
Quiz no u
#include <iostream>
using namespace std;
int main() {
int numBooks;
int points = 0;
Solution quizes
cout << "Enter the number of books purchased this month: ";
cin >> numBooks;
if (numBooks == 1) {
points = 5;
} else if (numBooks == 2) {
points = 15;
} else if (numBooks == 3) {
points = 30;
} else if (numBooks >= 4) {
points = 60;
cout << "Points earned: " << points << endl;
return 0;
Quiz no 4
#include <iostream>
using namespace std;
int main() {
string months[12] = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
int monthNumber;
cout << "Enter a number (1-12) to find the equivalent month: ";
Solution quizes
cin >> monthNumber;
if (monthNumber >= 1 && monthNumber <= 12) {
cout << months[monthNumber - 1] << endl;
} else {
cout << "Invalid input! Please enter a number between 1 and 12." << endl;
return 0;
Quiz no lab 4 A
#include <iostream>
using namespace std;
int main() {
const double PI = 3.14159;
double radius, area;
cout << "Enter the radius of the circle: ";
cin >> radius;
area = PI * radius * radius;
cout << "The area of the circle is: " << area << endl;
return 0;
B part
Solution quizes
#include <iostream>
using namespace std;
int main() {
double fahrenheit, celsius;
cout << "Enter temperature in Fahrenheit: ";
cin >> fahrenheit;
celsius = (fahrenheit - 32) * 5 / 9;
cout << "Temperature in Celsius: " << celsius << " C" << endl;
return 0;
Quiz no 4 b
#include <iostream>
using namespace std;
int main() {
int choice;
int num1, num2;
cout << "Menu:" << endl;
cout << "1. Find the sum of two numbers" << endl;
cout << "2. Check if the numbers are even or odd" << endl;
cout << "Enter your choice: ";
cin >> choice;
Solution quizes
if (choice == 1) {
cout << "Enter two numbers: ";
cin >> num1 >> num2;
cout << "Sum: " << num1 + num2 << endl;
} else if (choice == 2) {
cout << "Enter two numbers: ";
cin >> num1 >> num2;
if (num1 % 2 == 0) {
cout << num1 << " is even" << endl;
} else {
cout << num1 << " is odd" << endl;
if (num2 % 2 == 0) {
cout << num2 << " is even" << endl;
} else {
cout << num2 << " is odd" << endl;
} else {
cout << "Invalid choice" << endl;
return 0;