Girilen 10 tamsayının negatif ve pozitif olanlarının toplamını ve sayısını bulan C programı
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
int main()
{
int a,i,neg,poz,poz_say,neg_say;
neg=0;
poz=0;
poz_say=0;
neg_say=0;
for(i=1;i<11;i++)
{
printf("a sayisini gir:");scanf("%d",&a);
if(a<0)
{neg=neg+a;
neg_say=neg_say+1;
}
if(a>0)
{poz=poz+a;
poz_say=poz_say+1;
}
}
printf("poz=%d",poz);
printf("\npoz=%d",neg);
printf("\nnegsay=%d",neg_say);
printf("\npozsay=%d",poz_say);
return 0;
}
Hiç yorum yok:
Yorum Gönder