Hızlı Konu Açma

Hızlı Konu Açmak için tıklayınız.

Son Mesajlar

Konulardaki Son Mesajlar

Reklam

Forumda Reklam Vermek İçin Bize Ulaşın

C++ / Switch Kullanimi

YaSa22

Fahri Üye
Fahri Üye
Katılım
12 Temmuz 2014
Mesajlar
2,293
Tepkime puanı
2
Puanları
0
Konum
GTA
C++ / Switch Kullanimi

Switch Kullanimina Bir Örnek


#include <iostream>

using std::cin;

using std::cout;

using std::endl;



int main() {

//variable declaretions

int num1,num2;

char operation;



//read two integer

cout<< “Enter two integer : ”;

cin>>num1>>num2;



//read operation code

cout<< “Enter a select code:” <<endl;

cout<< “ a for addition” <<endl;

cout<< “ m for multiplication” <<endl;

cout<< “ d for division : ”;

cin>>operation;



switch (operation){

case ‘a’:

case ‘A’ :

cout<< “The sum of the numbers is ”<<num1+num2<<endl;

case ‘m’:

case ‘M’ :

cout<< “The product of the numbers is ”<<num1*num2<<endl;

case ‘d’:

case ‘D’ :

cout<< “The division of the numbers is ”<<num1/num2<<endl;

default :

cout<< “Operation code is not acceptable”<<endl;

}



return 0;

}
 

Users Who Are Viewing This Konu (Users: 0, Guests: 1)

Üst