write a c program to print the primary number or not using goto statement


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 noprime;

    printf("enter a value: ");

    scanf("%d", &no);

    for (int i = 2i <= no / 2i++)

    {

        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!

Follow our page for regular updates.

0 Comments