File: Stare vježbe/vjezbe06/35__funkcije.c
/* 35__funkcije.c Prvi program koji koristi funkcije. */ #include <stdio.h> int ucitaj_broj () { int broj; scanf ("%d", &broj); return broj; } int broj_djelitelja ( int broj ) { int total=0, i; if (broj <= 0) return 0; for (i=1; i<broj/2+1; i++) if (!(broj%i)) total++; return total+1; } void ispisi_broj ( int broj, int koliko_djelitelja ) { printf ("Broj %d ima %d djelitelja.\n", broj, koliko_djelitelja ); } int main () { int n, n_djel; n=ucitaj_broj(); n_djel=broj_djelitelja (n); ispisi_broj (n, n_djel); return 0; }
|