Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
32 views2 pages

Partb CPP

The document contains multiple C++ programs that demonstrate basic input and output operations. Programs include calculating the sum of two integers, determining if a number is even or odd, and calculating simple interest based on user input. Each program prompts the user for input and displays the result accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Partb CPP

The document contains multiple C++ programs that demonstrate basic input and output operations. Programs include calculating the sum of two integers, determining if a number is even or odd, and calculating simple interest based on user input. Each program prompts the user for input and displays the result accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

q14

#include <iostream>
using namespace std;
int main() {
int num1, num2, sum;
cout << "Enter first integer: ";
cin >> num1;
cout << "Enter second integer: ";
cin >> num2;
sum = num1 + num2;
cout << "The sum of " << num1 << " and " << num2 << " is: " << sum << endl;
return 0;
}
Q15
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter an integer: ";
cin >> num;
if (num % 2 == 0) {
cout << num << " is even." << endl;
} else {
cout << num << " is odd." << endl;
}
return 0;
}
Q16
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number: ";
cin >> num;
cout << "You entered: " << num << endl;
return 0;
}
Q17
#include <iostream>
using namespace std;
int main() {
int num;
cin >> num;
cout << num << endl;
return 0;
}
Q18
#include <iostream>
using namespace std;
int main() {

float principal, rate, time, simpleInterest;


cout << "Enter the principal amount: ";
cin >> principal;
cout << "Enter the rate of interest: ";
cin >> rate;
cout << "Enter the time period (in years): ";
cin >> time;
simpleInterest = (principal * rate * time) / 100;
cout << "The simple interest is: " << simpleInterest << endl;
return 0;
}

You might also like