28 Şubat 2015 Cumartesi

3 Basamaklı Rastgele Sayıların Fonksiyona Gönderilip Adetinin Döndürülmesi



#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
int fonk(int *);
int main(){
 int sayi[20],i,adet;
 srand(time(NULL));
 for(i=0;i<20;i++){
  sayi[i]=100+rand()%899;
 }
 adet=fonk(&sayi[0]);
 printf("%d sayi 3 e tam bolunur.\n\n",adet);
 for(i=0;i<20;i++){
  printf("%d\n",sayi[i]);
 }
 getch();
 return 0;
}
int fonk(int *ptr){
 int n=0,i;
 for(i=0;i<20;i++){
  if(ptr[i]%3==0){
   n++;
  }
 }
 return n;
}


Hiç yorum yok:

Yorum Gönder