0% found this document useful (0 votes)
25 views6 pages

Task 02

The document contains code snippets that demonstrate various ways to check if a number is even or odd, check if a letter is a vowel or consonant, find the largest of three numbers, handle division by zero, convert between Fahrenheit and Celsius temperatures, and check if the greater of two positive numbers is even.

Uploaded by

fadymamdouh2515
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)
25 views6 pages

Task 02

The document contains code snippets that demonstrate various ways to check if a number is even or odd, check if a letter is a vowel or consonant, find the largest of three numbers, handle division by zero, convert between Fahrenheit and Celsius temperatures, and check if the greater of two positive numbers is even.

Uploaded by

fadymamdouh2515
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/ 6

#include <iostream>

using namespace std;

int main()

//01 cheack number ood or even

cout << "01- odd or even\n";

cout << "___________________________________________\n";

int number;

cout << "please enter the number:\n";

cin >> number;

if (number % 2 == 0) {

cout << "the number is even\n";

else {

cout << "the number is odd\n";

cout << "_________________________________________\n";

//02 cheack vowel or consonant

cout << "02- vowel or consonant\n";

cout << "____________________________________________\n";


char letter;

cout << "please enter the letter to cheack:\n";

cin >> letter;

switch (letter) {

case 'a':

cout << "vowel\n";

break;

case 'o':

cout << "vowel\n";

break;

case 'u':

cout << "vowel\n";

break;

case 'e':

cout << "vowel\n";

break;

case 'i':

cout << "vowel\n";

break;

case 'A':

cout << "vowel\n";

break;

case 'O':

cout << "vowel\n";

break;
case 'U':

cout << "vowel\n";

break;

case 'E':

cout << "vowel\n";

break;

case 'I':

cout << "vowel\n";

break;

default:

cout << "consonant\n";

/* char letter;

cout << "please enter the letter to cheack:\n";

cin >> letter;

if(letter=='a'||letter=='A'||letter=='e'||letter=='E'||letter=='u'||letter=='U'||letter=='o'||
letter=='O'||letter=='i'||letter=='I'){

cout<<"vowel\n";

else{

cout<<"consonat\n";

}*/

cout << "____________________________________________\n";

//03 find the largest number

cout << "03- what is the largest number \n";


cout << "____________________________________________\n";

int x, y, z;

cout << "please enter the first number\n";

cin >> x;

cout << "please enter the second number\n";

cin >> y;

cout << "please enter the third number\n";

cin >> z;

(x > y && x > z) ? cout << "the first is larger\n" : (y > z) ? cout << "the second is larger\n" : cout <<
"the third is larger\n";

cout << "____________________________________________\n";

//04 divide tow number and print unknwon if zero

cout << "04- the divde\n";

cout << "____________________________________________\n";

int num, num2, num3;

cout << "please enter the first number\n";

cin >> num;

cout << "please enter the second number\n";

cin >> num2;

num3 = num / num2;

if (num3 <= 0) {

cout << "unkwon\n";

}
else {

cout << "="<<num3<<endl;

cout << "____________________________________________\n";

//05 convert temp from fahrenheit to celsiue

cout << "05- convert from fahrenheit to celsiue\n";

cout << "____________________________________________\n";

int fahrenheit;

cout << "please enter the fahrenheit degree= ";

cin >> fahrenheit;

float celsius = (fahrenheit - 32) / 1.8;

cout << "celsius=" << celsius<<endl;

cout << "____________________________________________\n";

//06 read 2 positive num. and print if evev

cout << "06- even greater num\n";

cout << "____________________________________________\n";

int ex, ey;

cout << "please enter the first number=";

cin >> ex;

cout << "please enter the second number=";

cin >> ey;

if (ex > ey) {

if (ex % 2 == 0) {
cout << ex<<endl;

if (ey > ex){

if (ey % 2 == 0) {

cout << ey<<endl;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy