1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#include <conio.h> #include <iostream.h> #include <string> /*---Tanımlamalar---*/ //Metotlar void metot1(); void metot2(bool); void metot3(int, int); void metot4(int, float, float); //Fonksiyonlar string fonksiyon1(); int fonksiyon2(int); float fonksiyon3(float, float); bool fonksiyon4(int, float, float); main(){ /*---Kullanma/Çağırma---*/ //Metotlar metot1(); metot2(false); metot3(3, 5); metot4(1, 2.34, 5.67); //Fonksiyonlar cout<<"String deger: "<<fonksiyon1()<<endl; cout<<"Tam sayinin yarisi: "<<fonksiyon2(10)<<endl; cout<<"Reel sayilarin carpimi: "<<fonksiyon3(1.2, 3.4)<<endl; cout<<"Sayilarin karsilastirilmasi: "<<fonksiyon4(1, 2.34, 5.67)<<endl; getch(); } /*---Kodlar---*/ //Metotlar void metot1(){ cout<<endl<<"Metot1 calisti."<<endl; } void metot2(bool dogruYanlis){ cout<<endl<<"Metot2'ye gelen bool deger: "<<((dogruYanlis==1)?"Dogru":"Yanlis")<<endl; } void metot3(int x, int y){ cout<<endl<<"Metot3'e gelen ilk tam sayi: "<<x<<", ikinci tam sayi: "<<y; cout<<endl<<"Tam sayilarin toplami: "<<x+y<<endl; } void metot4(int x, float y, float z){ cout<<endl<<"Metot4'e gelen ilk tam sayi: "<<x<<", ikinci reel sayi: "<<y<<", ucuncu reel sayi: "<<z; cout<<endl<<"Reel sayilarin toplaminin, tam sayi ile carpimi:"<<x*(y+z)<<endl; } //Fonksiyonlar string fonksiyon1(){ cout<<endl; return "Fonksiyon1 calisti."; } int fonksiyon2(int x){ cout<<endl<<"Fonksiyon2'ye gelen tam sayi: "<<x<<endl; return x/2; } float fonksiyon3(float x, float y){ cout<<endl<<"Fonksiyon3'e gelen ilk reel sayi: "<<x<<", ikinci reel sayi: "<<y<<endl; return x*y; } bool fonksiyon4(int x, float y, float z){ cout<<endl<<"Fonksiyon4'e gelen tam sayi: "<<x<<", ilk reel sayi: "<<y<<", ikinci reel sayi: "<<z<<endl; return (x>y+z); } |