Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Task 1

#include <iostream>

using namespace std;

int main() {

int number1;

int number2;

cout << "Enter the first number: ";

cin >> number1;

cout << "Enter the second number: ";

cin >> number2;

cout << "Addition of " << number1 << " and " << number2 << ": " << number1 + number2 << endl;

cout << "Subtraction of " << number1 << " and " << number2 << ": " << number1 - number2 << endl;

cout << "Multiplication of " << number1 << " and " << number2 << ": " << number1 * number2 <<
endl;

if (number2 != 0) {

cout << "Quotient of " << number1 << " and " << number2 << ": " << number1 / number2 << endl;

} else {

cout << "Cannot divide by zero." << endl;

return 0;

Task 2

#include <iostream>
using namespace std;

int main() {

int num;

cout << "Enter an integer: ";

cin >> num;

bool isPrime = true;

if (num <= 1)

isPrime = false;

for (int i = 2; i * i <= num; i++) {

if (num % i == 0) {

isPrime = false;

break;

if (isPrime)

cout << "Prime number." << endl;

else

cout << "Not a prime number." << endl;

return 0;

Task 3

#include<iostream>
using namespace std;

int main()

char arr[50];

cin.getline(arr,50);

int length=0;

while(arr[length] !='/0'i--){

legth++;

for(int i=length -1; i>=0; i--){

cout<<arr[i]

return 0;

Task 4

#include<iostream>

using namespace std;

int main() {

int arr[5];

int sum = 0;

cout << "Enter the marks for the first five subjects:" << endl;

for(int i = 0; i < 5; i++) {

cin >> arr[i];

for(int i = 0; i < 5; i++) {

sum += arr[i];

}
int average = sum / 5;

cout << "Sum: " << sum << endl;

cout << "Average: " << average << endl;

return 0;

Task 5

#include<iostream>

using namespace std;

int main()

char arr[50];

cin.getline(arr,50);

int length=0;

while(arr[length] !='/0'i--){

legth++;

for(int i=length -1; i>=0; i--){

cout<<arr[i]

return 0;

You might also like