Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[help] Solving Errors & goto

Status
Not open for further replies.

shyg

Technical User
Jul 12, 2004
20
0
0
US
I am working on a program which test to see if a number is perfect but before I can ensure that I am testing for perfect numbers properly. I have to compile the code to see if the test results are correct.

Code:
#include <stdio.h>

int readud(int pVal, int perfect() ) // Read User Data
{
	printf ("Please Enter An Integer To Sum: ");
	scanf ("%d",pVal);
		if (pVal > 1000)

			{printf ("\n\tError: The integer you entered exceeds the limit.\n\tPlease try again and enter an integer between 1 and 1000.\n\nPlease Enter An Integer To Sum: ");	

		}else
		
		return(pVal);       
}


int perfect(int n) // Do The Math
{
		if ((n%2) == 0)
		    {printf("True: The integer you entered is perfect\n");
			printf("%d\t",n); // value found

		}else 

			{printf ("\n\tFalse: The integer you entered is not perfect.\n\tPlease try again.\n\nPlease Enter An Integer To Sum: ");
}
}


main()
{
	int n, pVal;

	pVal = readud();
	n = perfect();
	
	printf("True: The integer you entered is perfect\n\n%d\t",n);
	
	return 0;
}

Errors are as follows

Line 4 & 18 - too few arguments to

Line 34 & 35 - at this point in file


How do I use "goto" so that I can tell the program to go to a certian line or a certian function?
 
scanf ("%d",pVal); // no no, it should be scanf("%d", &pVal);
 
1. Is perfect?!... Is even!
2. Right signature for your readud() function is:
Code:
int readud(void)
{
   int x;
   ...
   scanf("%d",&x);
   ...
}
3. Unfriendly user interface: do prompt with right range 1..1000 before, not after user input...
4. Rather strange conclusion: True: The integer...
It's FALSE for 1, 3, ... - why True:[/i}?..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top