my professor has a assignment for us... this is the directions

"write a c++ program that declares an array alpha of 50 elements of type float initializxa the array the 1st 25 elemensts are equal to the square of the index variable and the remaining elements are equal to 3x the variable

heres my code

#include <iostream>
#include <cmath> 
using namespace std;
int main (){

int alpha[50];
for (int b=0; b>25; b++);
for (int a=0; a>25; a++);


alpha[a]= b*b;

cout<< alpha[b]<<"\n";
return 0;
}

the out put is 0 it doesnt ouput the 50 elements on the program..

ill be aso thankful if youll consider this...thanks

Your array is of type int not float.

Plus your for statements are wrong.

how can i make it correct?

As Gerald said, you have declared an array of ints not floats. You should be able to figure that out by yourself.

Here is an example for loop that you can learn from:

#include <iostream>
using namespace std;

int main() {
	int Example[10];  // you want to declare this as an array of floats not ints

	for (int i = 0; i < 10; i++) {     // loop 10 times (from 0 to 9)
		if (i < 5) {               // for first half of array
			Example[i] = i;    // assign value of i
		} else {	           // for second half of array
			Example[i] = i * 2;// assign value of i * 2
		}
		cout << Example[i] << endl;// display values of array
	}

	return 0;
}

That might give you an idea of how to approach the assignment.
Ask if you have any further specific questions

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.