hey guys i need to make this code into seprate functions, i have no idea where to start. help !!

Basically its a fourier graph program in which the user enters the number of interations and the program pumps out a graph .

Code:

#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
int not;
double unrsum=0;
const int asize =61;
int rsum;
double xy=40/M_PI;
int arrayx[asize];
int max=0;
int min=0;
cout << "FOURIER SERIES GRAPH\n";
cout << "No. of terms = ";
cin>>not;
while (not<=0)
{
cout << "No. of terms must be greater than zero."<<endl;
cout << "Enter No. of terms: ";
cin>> not;
}
for(int theta=0;theta<=360;theta+=6)
{
for(int n=0;n<not;n++)
{
double thetarad;
thetarad=theta*((M_PI)/180);
unrsum+=((sin((2*n + 1)*((thetarad))))/(2*n + 1));;
}
if (unrsum > 0)
{
rsum = xy*unrsum + 0.5;
}
else
{
rsum = xy*unrsum - 0.5;
}
int r=theta/6;
arrayx[r]=rsum;
unrsum=0;
}
max = arrayx[0];
for (int i = 1; i < asize; i++)
{
if (arrayx[i] > max)
{
max = arrayx[i];
}
}
min =arrayx[0];
for (int i = 1; i < asize; i++)
{
if (arrayx[i] < min)
{
min = arrayx[i];
}
}
{ for(int i =max;i>=min;i--)
{
if (i==0)
{
cout <<setw(3)<<i << " ";
for (int x=0;x<=asize;x++){
if(i==arrayx[x])
{
cout << "*";
}
else
{
cout << "-";
}
}
}
else
{ cout <<setw(3)<<i<<" ";
for (int x=0;x<=asize;x++){
if(i==arrayx[x])
{
cout << "*";
}
else
{
cout << " ";
}
}
}
cout <<endl;
}
}
}

thanks so much !