Knowledge of Engineering
This site encapsulates the tips you require to be successful in engineering.
Pages
Home
Computer Programming Old Questions IOE
Object Oriented Programmming in C++
Electrical Machine Design
Artificial Neural Network (ANN)
Old Questions Institute of Engineering (IOE), TU
Monday, December 13, 2010
Program to check whether the entered number is prime or not
#include<stdio.h>
int main( )
{
int num, i ;
printf ( "Enter a number:" ) ;
scanf ( "%d", &num ) ;
i = 2 ;
while ( i <= num - 1 )
{
if ( num % i == 0 )
{
printf ( "Not a prime number" ) ;
break ;
}
i++ ;
}
if ( i == num )
printf ( "Prime number" ) ;
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment