Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: C  |  size: 0.80 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<stdio.h>
  2. #include<conio.h>
  3. int main(void) {
  4.     int luku, summa = 0;
  5.     int lkm = 0;
  6.     int pienin;
  7.     int i;
  8.     for (i=0; luku!=0; i++) {
  9.     printf ("\nAnna positiivinen luku. ");
  10.     scanf ("\n%d", &luku);
  11.     while (luku < 0) {
  12.           printf ("\nAnnoit negatiivisen luvun. ");
  13.           printf ("\nAnna positiivinen luku. ");
  14.           scanf ("\n%d", &luku);
  15.           }
  16.     if (i == 0) {
  17.     pienin = luku;
  18.     }
  19.     if (luku > 0) {
  20.              summa = summa+luku;
  21.              lkm++;
  22.              if (pienin > luku | pienin < 0) {
  23.                         pienin = luku;
  24.                         }
  25.              }
  26.     }
  27.     float keskiarvo = (float)summa/lkm;
  28.     printf ("\nLukujen keskiarvo %.1f, Pienin luku %d", keskiarvo, pienin);
  29.     getch();
  30.     return 0;
  31. }