Created
March 24, 2013 14:27
-
-
Save austa/5232165 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| * File: main.c | |
| * Author: alaattin | |
| * | |
| * Created on 24 Mart 2013 Pazar, 16:18 | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| /* | |
| * | |
| */ | |
| int faktoriyel(int); | |
| int main(int argc, char** argv) { | |
| int sonuc, sayi; | |
| int (*fonkPtr) (int); // Prototip tanımlamaya benziyor.Sadece fonksiyon adı * ile birlikte parantez içinde. | |
| fonkPtr = faktoriyel; // Fonksiyon adı aynı zamanda fonksiyonun adresini verir. | |
| printf("sayı giriniz: \n"); | |
| scanf("%d", &sayi); | |
| printf ("Sonucumuz: %d \n", sonuc = (*fonkPtr)(sayi)); | |
| return (EXIT_SUCCESS); | |
| } | |
| int faktoriyel(int sayi){ | |
| int sonuc = 1, i = 0; | |
| if (sayi == 1 && sayi == 0) { | |
| return sonuc; | |
| } | |
| else{ | |
| for(i = sayi; i > 0; i--){ | |
| sonuc *= i; | |
| } | |
| } | |
| return sonuc; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment