Created
March 28, 2013 21:37
-
-
Save gokhanyavas/5267028 to your computer and use it in GitHub Desktop.
Dışarıdan girilen bir n tam sayısına kadar olan tek tam sayiların toplamını bulan c programı.
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
// Dışarıdan girilen bir n tam sayısına kadar olan tek tam sayiların toplamını | |
// bulan program. | |
#include <stdio.h> | |
#include <conio.h> | |
int main() | |
{ | |
int i,n,sonuc, adet; | |
printf("N sayisini giriniz :"); | |
scanf("%d", &n); | |
sonuc = 0; | |
i = 1; | |
adet = 0; | |
while (i<=n) | |
{ | |
sonuc = sonuc+i; | |
i=i+2; | |
adet= adet+1; | |
} | |
printf ("%d e kadar olan sayilarin toplami : %d \n" ,n,sonuc ); | |
printf ("%d tane sayi vardir", adet ); | |
getch(); | |
// ekranın kapanmasını engelliyor.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment