5 Mart 2026
Fibonacci dizisi
#include <iostream>
using namespace std;
int fibo(int sira)
{
if (sira == 1) return 0;
if (sira == 2) return 1;
if (sira>=3) return fibo(sira-1) + fibo(sira-2);
}
int main() {
cout<<fibo(20);
return 0;
}
Faktöriyel hesaplama
#include <iostream>
using namespace std;
int fakt(int n)
{
if (n == 1) return 1;
else return fakt(n-1) * n;
}
int main() {
cout<<fakt(6);
return 0;
}
26 Mart 2026
Struct ve union örnekleri
#include <iostream>
using namespace std;
struct urun{
float fiyat;
int kdv;
int stok;
};
int main()
{
urun gofret;
gofret.fiyat = 10.20;
gofret.kdv = 8;
gofret.stok = 100;
urun cikolata;
cikolata.fiyat = 20;
cikolata.kdv = 8;
cikolata.stok = 10;
cout<<"çikolata stoğumuz: "<<cikolata.stok;
return 0;
}
#include <iostream>
using namespace std;
struct ogrenci{
string ad;
string soyad;
int dogumyili;
int numara;
bool aktif;
};
int main()
{
ogrenci ogr1;
ogr1.ad = "ali";
ogr1.soyad = "celik";
ogr1.numara = 20202020;
ogr1.dogumyili = 2004;
ogr1.aktif = true;
cout<<ogr1.ad<<" "<<ogr1.soyad;
ogrenci ogr2;
ogr2.ad = "ayşe";
ogr2.numara = 201040;
return 0;
#include <iostream>
using namespace std;
union urun{
float fiyat;
int kdv;
};
int main()
{
urun gofret;
gofret.fiyat = 5.20;
gofret.kdv = 10;
cout<<gofret.fiyat;
return 0;
}
