1. Toplama İşlemi
2. Celcius-Fahrenheit Dönüştürücü
3. Hesap Makinesi
4. Kombinasyon Hesaplama
Kaynak: www.turkhackteam.org
Kod:
#include <iostream>
using namespace std;
int main() {
double a,b;
cout << "Birinci Sayi : ";
cin >> a;
cout << "Ikinci Sayi : ";
cin >> b;
cout << "Toplam : " << a+b;
system("PAUSE");
return 0;
}
2. Celcius-Fahrenheit Dönüştürücü
Kod:
#include<stdio.h>
#include<conio.h>
voıd menu( );
voıd fahrenheit( );
voıd celsius( );
int main() {
char choise;
menu();
do {
clrscr();
menu();
scanf("%d",&choise);
switch(choise) {
case 1 : fahrenheit();break;
case 2 : celsius();break;
case 3 : printf("Program Sonu");break;
}
getch();
} while(choise!=3);
return 0;
}
voıd menu() {
printf("\n- MENU -\n");
printf("Fahrenheit'dan Celcius'a...........................1 \n");
printf("Celcius'dan Fahrenheit'a...........................2 \n");
printf("Programdan Cikis...................................3 \n");
printf("Bir Numara Secin ve Enter'a Basin ");
}
voıd fahrenheit() {
float fah,cel;
printf("Lutfen Fahrenheit Degerini Girin : ");
scanf("%f",&fah);
cel=5.0/9.0*(fah - 32.0);
printf("%f Fahrenheit = %f\n",fah,cel);
}
voıd celsius() {
float fah,cel;
printf("Lutfen Celcius Degerini Girin : ");
scanf("%f",&cel);
fah=9.0/5.0*cel + 32.0;
printf ("%f Celcius = %f ",cel,fah);
}
3. Hesap Makinesi
Kod:
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main () {
float a,b;
char islem;
printf ("Sirasiyla a ve b yi Giriniz ve Yapilacak Islemi Giriniz : ");
scanf ("%f %f %c", &a, &b, &islem);
switch (islem) {
case '+': printf ("a + b = %f\n",a+b); break;
case '-': printf ("a - b = %f\n",a-b); break;
case '*': printf ("a * b = %f\n",a*b); break;
case '/': printf ("a / b = %f\n",a/b); break;
case 'p': printf ("a ^ b = %f\n",pow(a,b)); break;
default : printf ("Created by Arsenik\n"); break;
}
printf("Kullandiginiz Icin Tesekkurler!\n");
getch();
return 0;
}
4. Kombinasyon Hesaplama
Kod:
#include <stdio.h>
int faktoriyel(int n) {
int i,top=1;
for(i=0; i<n; i++) {
top *= n-i;
}
return top;
}
int main() {
int n,r;
float com;
printf("C(n,r)\nn : ");
scanf("%d",&n);
printf("r : ",&r);
scanf("%d",&r);
com = faktoriyel(n)/(faktoriyel(r)*faktoriyel(n-r));
printf("%.2f",com);
system("PAUSE");
return 0;
}
Kaynak: www.turkhackteam.org