I have two programs that i have to write by next friday (april 1 ) but i have no idea how to do them. Can someone please help me out. These are the conditions for the 1st one:

1) read floating point numbers into an array until teh sum of those numbers exceeeds 100.At teh element where the sum becomes greater than 100, store a -1.0 to denote that end of the array. Now print the number of elements in the aarray, not including the -1.0.

Second one:
2) initialize an integer array with six elements. find the largest element and swap it with the number in the first element. FOr example, if the array is 40, 80,20,50,90,30, after the swap the array should become 90,80,20,50,40,30.

All 2 Replies

This is all i have so far and the point where i stopped. The condition for this problem is posted in the forums.
I would appreciate if you could help me.

const int point = 6;
float point[6], sum = 0.0;
int index;
count<<"Enter the floats: ";
for(index=0; sum !=100; index = index + 1)
{
cin<<point[index];
sum = sum + point[index];
}
if (point[inedx] > 100)
point[index] = -1.0;
cout<<"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.