Write a C Program to check number is prime or not using goto statement

#include <stdio.h>
/* Program to check number is prime or not
using goto statement.

Prime numbers have only 2 factors
1 and itself. */
void main()
{
int n=2,x=16,prime=1;
repeat:
if(x%n==0){
prime=0;
}
n++;
if(n<x) goto repeat;
if(prime==0){
printf(“The number is not a prime number.”);
}else{
printf(“The number is a prime number.”);
}

}

 

For Life time valid video tutorials of “C Programming For Beginners” course with quiz and certification : Click Here

Downloadable video tutorials of “C Programming For Beginners” for TTRC Player : Click Here

My Self Subrat Dash. I have completed my MSc in Information Technology. Since last 12 years i am teaching Math and Computer at TTRC Computer Institute situated at Rayagada, Odisha, India. I believe in conceptual learning, so i explain each and every concept with demos and examples, which makes it easier to understand.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!