Prime number
A primary number is a number that is not divisible except by 1 and itself number.
QUESTION:- write a c program to print the primary number or not using goto statement.
#include <stdio.h>
#include <conio.h>
void main()
{
int no, prime;
printf("enter a value: ");
scanf("%d", &no);
for (int i = 2; i <= no / 2; i++)
{
prime = no % i;
if (prime == 0)
{
printf("Not a prime number!\n");
goto end;
}
}
printf("prime number!\n");
end:
getch();
}
OUTPUT
enter a value: 10
Not a prime number!
0 Comments