i hove a problem about hot to write a program to determine if a number entered by a user is a prime number.
Program Input is : Prompt user for a number between 1 and 1000.
the probable Program Output is:
Echo the user input, display whether the number is a prime
number or not and the first smaller prime number and the first
bigger prime number.
my attempt to the code determine only weather the number is or not a prime number, please help me:
#include<stdio.h>
#include<math.h>
main()
{
long int a,b,c;
printf("Enter the number: ");
scanf("%ld",&a);
for (b=2;b<a;++b)
{
c= a%b;
if (c==0)
goto cool;
}
printf("\nThe number you enter is a prime number!");
goto fool;
cool: printf("\nThe number you enter is not a prime number!");
fool: printf("\n");
getch();
}