17 Kasım 2014 Pazartesi

c++ da 4 basamaklı bir sayıyının basamak değerini bulan program.

#include <stdlib.h>
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
int X, Y, Z, T , sayi;
cout << "4 Basamakli bir sayi girin:   ";          
cin >> sayi;
while (sayi<1000 || sayi>10000);

{
X = sayi / 1000;

Y = (sayi % 1000) / 100;

Z = (sayi % 100) / 10;

T = sayi % 10;


cout << endl << "Birler:  " << T << endl;

cout << endl << "Onlar:  " << Z << endl;

cout << endl << "yuzler:  " << Y << endl;

cout << endl << "Binler:  " << X << endl;

}
system("pause");

return 0;
}

c++ da öğrencinin vize,final ve devamsızlığını hesaplayıp geçip geçmediğini ,geçtiyse hangi harfle geçtiğini bulan program

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>

using namespace std;

int main()
{
int vize, final, devamsizlik;

char ortalama,vizeToplam,finalToplam;

int i = 1;
do

{
cout << i << ". ogrencinin vize notunu giriniz: ";

cin >> vize;

if (vize == -1)

{
cout << "program kapaniyor";
}


vizeToplam = (vize * 0.35);

if (vizeToplam < 20 || vizeToplam > 35)
{
cout << i << ". ogrenci basarisiz "<<endl<<endl;
}
else
{
cout << i << ". ogrencinin final notunu giriniz:  ";
cin >> final;


finalToplam = (final * 0.65);

cout << i << ". ogrencinin devamsiz gun sayisi:  ";
cin >> devamsizlik;


if (devamsizlik < 15 || devamsizlik > 30)
{
cout<<i<<". ogrenci devamsizliktan KALDI "<<endl<<endl;
}
else
{
ortalama = vizeToplam + vizeToplam;

if (0 <= ortalama && ortalama <= 44) cout<<i<<". Ogrencinin basari harf notu FF.. Ogrenci KALDI "<<endl<<endl;
else if (45 <= ortalama && ortalama <= 54) cout<<i<<". Ogrencinin basari harf notu DD.. Ogrenci GECTI "<<endl<<endl;
else if (55 <= ortalama && ortalama <= 69) cout<<i<<". Ogrencinin basari harf notu CC.. Ogrenci GECTI "<<endl<<endl;
else if (70 <= ortalama && ortalama <= 84) cout<<i<<". Ogrencinin basari harf notu BB.. Ogrenci GECTI"<<endl<<endl;
else if (85 <= ortalama && ortalama <= 100) cout<<i<<". Ogrencinin basari harf notu AA.. Ogrenci GECTI"<<endl<<endl;

}



}
i++;

}

while (vize != -1);



system("pause");

return 0;
}

c++ da fibonacci dizisi

#include "stdafx.h"
#include <iostream>

using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
int sayi1, sayi2, sayi3, max;

cout << "sayi giriniz:  ";
cin >> max;
sayi1 = 0;
sayi2 = 1;
sayi3 = 1;
cout << sayi1 << endl;
while (max>=sayi3)
{
cout << sayi3 << endl;
sayi3 = sayi1 + sayi2;
sayi1 = sayi2;
sayi2 = sayi3;


}
system("pause");
return 0;
}

c++ da bir sayının asal çarpanlarını bulma.

#include "stdafx.h"
#include <iostream>


using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
int sayi, i;

cout << " bir sayi giriniz:  ";
cin >> sayi;

cout << "carpan  " << endl;
cout << sayi << " Sayisinin asal carpanlari: " << endl;
for (i = 2; sayi != 1; i++)
{

if (sayi % i == 0)
{
sayi /= i;

cout << " "<< i<< endl;
i--;

}
}
cout << endl;
system("pause");
return 0;
}

C++ da üs alma fonksiyonu

#include <iostream>
#include <stdio.h>
#include <math.h>
//kütüphanelerimizi oluşturuyoruz
using namespace std;
int main(int argc, char** argv) {
//ilk önce değişkenlerimizi tanılıyoruz
         int x,y,z,;
cout<<"X sayisini giriniz: ";
cin>>x;
cout<<"Y sayisini giriniz: ";
cin>>y;
cout<<"Z sayisini giriniz: ";
cin>>z;
cout<<pow(x,a)+pow(y,b)+pow(z,c)<<endl;
         //a,b,c değerleri sayının üssü ne olmasını istiyorsak onu yapıyoruz
return 0;
}



Abdulkadir Dikmen