Răspuns:
1.#include<iostream>
using namespace std;
int main()
{
int a[100],i,j,n,s=0;
cin>>j;
cin>>n;
for(i=1;i<=j;i++)
cin>>a[i];
for(i=1;i<=n;i++)
s=s+a[i];
cout<<s;
return 0;
}
2.#include<iostream>
using namespace std;
int main()
{
int x[100],i,p=1,s=0,j=1;
for(i=1;i<=j;i++)
{
cin>>x[i];
if(x[i]==0)
break;
else
j++;
}
for(i=1;i<j;i++)
if(x[i]>0)
s=s+x[i];
else
p=p*x[i];
cout<<s<<endl<<p;
return 0;
}
Explicație: