👤

produsul si suma patratelor elementelor dintr-un sir.va roooog , cat mai repede!

Răspuns :

int n,s=0,p=1,i;
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
{i=i*i;
s=s+i;
p=p*i;
}
cout<<"suma="<<s;
cout<<"produsul="<<p; (daca ai un sir pana la n)

int n,s=o,p=1,i,x;
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
{
cout<<"x=";cin>>x;
x=x*x;
s=s+x;
p=p*x;
}
cout<<s;
cout<<p; (pt sirul dat de tine)