27 Aralık 2014 Cumartesi

Girilen 10 sayıdan kaç negatif olduğunu bulmak C.

Klavyeden 10 tane tamsayı girilmesini isteyen ve bu girilen tamsayılardan kaç tanesinin negatif olduğunu bulan program

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int sayi,i;
    int sayac1=0,sayac2=0;

    for(i=0;i<10;i++)
    {

        printf("lutfen bir sayi giriniz : ");
        scanf("%d",&sayi);

        if(sayi<0)
        {
            sayac1++;
        }

        else
        {
            sayac2++;

        }

    }
    printf("negatif sayi adedi : %d \n",sayac1);
    printf("pozitif sayi adedi : %d",sayac2);

    return 0;

}

1 yorum: