Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n,cont=0,cifra,s=0;
cout<<"n=";
cin>>n;
while(n!=0)
{
cifra=n%10;
s+=cifra;
cont++;
n/=10;
}
cout<<s/cont;
return 0;
}
primu cod iti calculeaza partea intreaga din media aritmetica adica fara virgula
(8+4+6+8):4=6 rest 2
#include <iostream>
using namespace std;
int main()
{
int n,cont=0,cifra,s=0,p,c;
cout<<"n=";
cin>>n;
while(n!=0)
{
cifra=n%10;
s+=cifra;
cont++;
n/=10;
}
p=s/cont;
c=s%cont*10/cont;
cout<<p<<","<<c;
return 0;
}