Skip to content

Instantly share code, notes, and snippets.

@gokhanyavas
Created March 28, 2013 21:37
Show Gist options
  • Save gokhanyavas/5267028 to your computer and use it in GitHub Desktop.
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ı.
// 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