0

May somebody pliz help explain to me line by line of this c++ coding cause I can't seem to understand it:-

```
#include <stdio.h>
#include <stdlib.h>
#define SIZE 50
#define pi 3.14
void push(int i);
int pop(void);
void sort(int stack[SIZE],int numbers);
int *pointer, stack[SIZE],numbers;
void main(void)
{
int value,numbers,num,num2,num3,num4,array[5],num6,num7,num8;
float num5,num9;
num=0;
pointer = stack; // pointer points to the stack
printf("************************************************\n");
printf("----------------PROJECT-------------------------");
printf("\nYOU SHOULD INPUT INTEGERS;\nTHEIR TOTAL NUMBER SHOULD BE DIVISIBLE BY THREE\n");
printf("\nenter the number of integers you want to input::");
scanf("%d",&numbers);
while((numbers%3)!=0 ||numbers==0 )
{printf("the number is not divisible by 3\n");
printf("TRY AGAIN;\nenter the number again::");
scanf("%d",&numbers);}
do {
printf("\nEnter the values consequitively: ");
scanf("%d", &value);
if(value != 0)
{push(value);
}
num++;
} while(num<=(numbers-1));
printf("\n\n\nelements in the stack are::");
for(num=0;num<=(numbers-1);num++)
{
printf(" %d",stack[num]);
}
printf("\n\nlets now sort it\n");
printf("\npress 1 to sort it::");
scanf ("%d",&num3);
if(num3==1)
{sort(stack,numbers);
}
else
{
exit(1);
}
for(num6=0;num6<=((numbers/3)-1);num6++)
{printf("\n\nwe pop the elements in 3's\n");
for(num=0;num<=2;num++)
{ array[num]= pop();
printf(" %d",array[num]);
}
num2= array[0]*array[1];
num7=2*(array[0]+array[1]);
if(array[0]==array[1])
{
printf("\n\nthe first 2 elements form sides of a square whose area is %d",num2);
printf("\nthe perimeter of this square is %d::",num7);
}
else
{printf("\n\nthe first 2 elements form sides of a rectangle whose area is %d",num2);
printf("\nthe perimeter of this rectangle is %d::",num7);
}
num4=array[2]*array[2];
num5=num4*pi;
num8=2*array[2];
num9=num8*pi;
printf("\n\n\nthe the 3rd element forms the radius of a circle whose area is %f",num5);
printf("\nthe perimeter of this circle is %f::\n",num9);
}
printf("\n\n\n****************END OF PROGRAM*******************\n\n");
}
void push(int i)
{*pointer=i;
pointer++;}
void sort(int stack[SIZE],int numbers)
{
int num,t,number;
for (number=0;number<=(numbers-1);number++)
for(num=0;num<=(numbers-1);num++)
{
if (stack[num]>stack[num+1])
{ t=stack[num];
stack[num]=stack[num+1];
stack[num+1]=t;
}}
printf("\nthe sorted array is::");
for(num=1;num<=numbers;num++)
{
printf(" %d",stack[num]);
}}
int pop()
{int m;
m=*pointer;
pointer--;
return m;
}
```

*Edited 3 Years Ago by Reverend Jim*: Fixed formatting