KEMBAR78
Oops Assignment 1 | PDF | Namespace | Computer Programming
0% found this document useful (0 votes)
6 views16 pages

Oops Assignment 1

The document contains a series of C++ programming assignments that demonstrate various programming concepts such as calculating the area of a circle, performing arithmetic operations, converting uppercase letters to lowercase, and identifying the largest or smallest numbers. Each assignment includes the code and expected output. The assignments cover basic input/output operations, control structures, and loops.

Uploaded by

bizzylazing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views16 pages

Oops Assignment 1

The document contains a series of C++ programming assignments that demonstrate various programming concepts such as calculating the area of a circle, performing arithmetic operations, converting uppercase letters to lowercase, and identifying the largest or smallest numbers. Each assignment includes the code and expected output. The assignments cover basic input/output operations, control structures, and loops.

Uploaded by

bizzylazing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

OOPS ASSIGNMENT 1

1. #include <iostream>
using namespace std;
int main ()
{
double radius, area;
const double PI = 3.14159;
cout << "Enter the radius of the circle: ";
cin >> radius;

area = PI*radius*radius;
cout << "area of the circle is : " << area << endl;
return 0;
}

OUTPUT:

2. #include <iostream>
using namespace std;
int main ()
{
int num1, num2;
cout << "enter num1 : ";
cin >> num1;

cout << "enter num2 : ";


cin >> num2;

cout << "\nArithmetic Operations:\n";


cout << num1 << " + " << num2 << " = " << (num1 +
num2) << endl;
cout << num1 << " - " << num2 << " = " << (num1 -
num2) << endl;
cout << num1 << " * " << num2 << " = " << (num1 *
num2) << endl;

if (num2 != 0)
{
cout << num1 << " / " << num2 << " = " << (num1 /
num2) << endl;
cout << num1 << " % " << num2 << " = " << (num1 %
num2) << endl;
}

else
{
cout << "Division and modulus not possible (division
by zero)." << endl;
}

return 0;
}

OUTPUT:
3. #include <iostream>
using namespace std;
int main ()
{
char ch;

cout << "enter an uppercase letter : ";


cin >> ch;

char lower = ch + 32;


cout << "Lowercase letter: " << lower << endl;

return 0;
}

OUTPUT:

4. #include <iostream>
using namespace std;
int main()
{
int num;

cout << "enter an integer : ";


cin >> num;

cout << "\nNumber in decimal : " << dec << num <<
endl;
cout << "Number in octal : " << oct << num << endl;
cout << "Number in hexadecimal: " << hex << num <<
endl;

return 0;
}

OUTPUT:
5. #include <iostream>
using namespace std;
int main()
{
char ch;

cout << "enter a character : ";


cin >> ch;

if (ch >= 'A' && ch <= 'Z')


{
cout << " it is an uppercase letter." << endl;
}

else if (ch >= 'a' && ch <= 'z')


{
cout << " it is a lowercase letter." << endl;
}

else if (ch >= '0' && ch <= '9')


{
cout << "it is a digit." << endl;
}

else
{
cout << "it is neither a letter nor a digit." << endl;
}

return 0;
}

OUTPUT:
6. #include <iostream>
using namespace std;
int main()
{
int num1, num2, num3;

cout << " enter num1 : ";


cin >> num1;

cout << " enter num2 : ";


cin >> num2;

cout << "enter num3 : ";


cin >> num3;

if(num1 >= num2 && num1 >= num3)


{
cout << " the biggest number is : " << num1 << endl;
}
else if(num2 >= num1 && num2 >= num3)
{
cout<< " the biggest number is : " << num2 << endl;
}

else
{
cout << " the biggest number is : " << num3 << endl;
}

return 0;
}

OUTPUT:

7. #include <iostream>
using namespace std;
int main()
{
int day;

cout << "Enter day number (1-7): ";


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;
}

return 0;
}

OUTPUT:

8. #include <iostream>
using namespace std;
int main()
{
int num = 1;

cout << "Even numbers between 1 and 100:\n";


while (num <= 100)
{
if (num % 2 == 0)
{
cout << num << " ";
}
num++;
}

num = 1; // reset for odd numbers


cout << "\n\nOdd numbers between 1 and 100:\n";
while (num <= 100)
{
if (num % 2 != 0)
{
cout << num << " ";
}
num++;
}

cout << endl;

return 0;
}

OUTPUT:
9. #include <iostream>
using namespace std;

int main()
{
int num;

cout << "Enter a number (0-9): ";


cin >> num;

switch (num)
{
case 0: cout << "Zero" << endl; break;
case 1: cout << "One" << endl; break;
case 2: cout << "Two" << endl; break;
case 3: cout << "Three" << endl; break;
case 4: cout << "Four" << endl; break;
case 5: cout << "Five" << endl; break;
case 6: cout << "Six" << endl; break;
case 7: cout << "Seven" << endl; break;
case 8: cout << "Eight" << endl; break;
case 9: cout << "Nine" << endl; break;
default: cout << "Invalid input! Please enter a
number between 0 and 9." << endl;
}

return 0;

OUTPUT:

10. #include <iostream>


using namespace std;

int main() {
int num, smallest;

cout << "Enter 10 numbers:\n";


cin >> smallest;

for (int i = 1; i < 10; i++)


{
cin >> num;
if (num < smallest)
{
smallest = num;
}
}

cout << "The smallest number is: " << smallest << endl;

return 0;

OUTPUT:

You might also like