Assignment

The array of real numbers is set.
a) To delete from the array positive elements.
b) To calculate the sum of negative elements in the array.
c) To calculate minimum of positive elements in the array.
solve using functions
Please note, that this is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attemts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find deriviative of function without knowledge in ariphmetics, you cannot do more complex tasks in programming without clear understanding of basics
this is what i did but it doesnt run


#include "stdafx.h"
#include <iostream>
using namespace std;
#define del_array
int _tmain(int argc, _TCHAR* argv[])
{
int z[40];
int i,imin,n;
float k,S,min;

cout<<"n="; cin>>n;
cout<< "please enter "<<n<<" intergers:" <<endl;
for(int i=0;i<n;i++)
{
cin>>z[i];
}
cout<< "\n values in array are now:";
for(i=0;i<n;i++)cout <<" "<<z[i];
cout <<endl;// for inputing of array

for(k=i=0;i<n;i++)
if(z[i]>0)
{k++;
if (k==1)
{min=z[i];imin=i;}
else
if (z[i]<min)
{min=z[i];imin=i;}}
cout<<"min="<<min<<"\n"<<endl;
{
int *z;int n,i;
cout<<"n=";cin>>n;
z=new int[n];
cout<<"Array z/n";
for(i=0;i<n;i++)
cin>>z[i];
for(i=0;i<n;)
if(z[i]>0);del_array(z,i&n)else i++;
if(z[i]>0) n=del_array(z,i,n)else i++;
cout<<"output array z\n";
for(i=0;i<n;i++)
cout<<z[i]<<"t";
}
return 0;
}
Error 5 error C2143: syntax error : missing ';' before 'else' ln41 col1
Error 7 error C2143: syntax error : missing ';' before 'else' ln42 col1
Error 6 error C2181: illegal else without matching if ln41 col1
8 IntelliSense: expected a ';' ln41 col28
9 IntelliSense: expected a ';' ln42 col30
So you missed ; before else in two lines and got an extra ; directly after if condition.

I think error messages are descriptive enough
Topic archived. No new replies allowed.