Code:
#include <stdio.h>
#include <math.h>
void main (void)
{
int m,k,num,x[50];
for(m=1;m<=6;m++)
{
printf("Enter the number of numbers to be entered\n");
scanf("%d",&num);
printf("\nNow scan in those numbers\n");
for(k=1;k<=num;k++);
{
scanf("%d",&x[k]);
}
printf("\n");
for (k=1;k<num;k++)
{
if(x[k+1]==x[k]*x[k])goto square;
else goto cool;
}
square:printf("square\n");
cool:printf("cool\n\n");
}
}
The object of the program is to A) scan in the total numbers you are entering. B) Enter the numbers, C) Check to see if the next number is the square of the previous.
Ex/ Enter the amount of numbers: 3
Enter the numbers: 3 9 81
If they are the sequential square of the previous, then it will print the word square, and start the program over for a new set of data.
When it is done, it will have a list of words, "Square" if the entries follow the parameters, "cool" if they do not.
The problem I am having is, when it goes to check if it follows the parameters, the code doesnt work.
OUTPUT:
Code:
Enter the number of numbers to be entered
3
Now scan in those numbers
3 9 81
cool
Enter the number of numbers to be entered
Now scan in those numbers
cool
Enter the number of numbers to be entered
FOr some reason, it prints enter the numbers to be entered once, prints now scan in those numbers, cool, before printing "enter the number of numbers to be entered" and allowing me to scan in the next data set.
After tracing the program, I cant make heads or tails of where I am going wrong, and why I am getting multiple instances of those print lines