Last active
November 28, 2023 01:43
-
-
Save eminadiguzel/eaec5ee2d1f86da1b7942c818ae41588 to your computer and use it in GitHub Desktop.
C++ programlama dilinde float, integer vb. veri türlerinin bölümü ders notlarım
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int sayi=9; //integer(tam sayı) (sayı integer oluyor) | |
float a,b,c; //float (ondalıklı) (a,b,c float yani ondalıklı(noktalı) olur) | |
a=sayi/4; //sonuç:2 olur (Tam sayının tam sayıya bölümü integer yani tam sayı olur) | |
b=sayi/4.0; //sonuç:2.25 olur. (Tam sayı(int) ile ondalıklı sayının (float) bölümü ondalıklı olur(float) | |
c=(float)sayi/4; //sonuç:2.25 olur. Ondalıklı sayı(float) ile tam sayı(integer) bölünürse sonuç float olur. | |
cout<<"a degeri="<<a<<endl; | |
cout<<"b degeri="<<b<<endl; | |
cout<<"c degeri="<<c<<endl; | |
return 0; | |
} | |
Bu kodun çıktısı şöyle olmaktadır; | |
a degeri=2 | |
b degeri=2.25 | |
c degeri=2.25 | |
-------------aynı kodun türleriyle oynayalım----------- | |
using namespace std; | |
int main() { | |
float sayi=9; //float | |
float a,b,c; //float | |
a=sayi/4; //float sayı integer sayıya bölünür float olur | |
b=sayi/4.0; //float bir sayı float bir sayıya bölünür, sonuç float olur | |
c=(float)sayi/4; //float bir sayı integer ile bölünür sonuç float olur | |
cout<<"a degeri="<<a<<endl; | |
cout<<"b degeri="<<b<<endl; | |
cout<<"c degeri="<<c<<endl; | |
return 0; | |
} | |
Bu kodun çıktısı şöyle olmaktadır; | |
a degeri=2.25 | |
b degeri=2.25 | |
c degeri=2.25 | |
* bu kodlar Elginkan vakfının online c+ kursundan alınmıştır. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment