Created
March 13, 2019 19:32
-
-
Save cipi1965/ad2fb6b4f3cc039295793b5479791209 to your computer and use it in GitHub Desktop.
main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// test | |
// | |
// Created by Matteo Piccina on 13/03/2019. | |
// Copyright © 2019 Matteo Piccina. All rights reserved. | |
// | |
#include <iostream> | |
int main(int argc, const char * argv[]) { | |
int i, num, somma=0, cont=0; | |
double media; | |
printf("\nInserisci un numero: "); | |
scanf("%d", &num); | |
for (i=1; i <= num; i++) { | |
if (num % i == 0) { | |
cont++; | |
somma = somma + i; | |
} | |
} | |
media = somma / cont; | |
printf("\nLa somma dei divisori di %d è %d", num, somma); | |
printf("\nLa media dei divisori di %d è %f", num, media); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment