write c++ code to get following output 0,1,4,9,16,25 (use array)
#include <iostream>
using namespace std;
int main()
{
int arr[6] = { 0,1,2,3,4,5 };
for (int i = 0; i < 6; i++)
{
if(i!=5)
cout << arr[i] * arr[i] << ",";
else
cout << arr[i] * arr[i];
}
}
Comments
Leave a comment