GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO TEST THE GIVEN NUMBER IS PRIME NUMBER (OR) NOT USING FUNCTIONS.

AIM:Aprogram to test the given number is prime number (or) not using functions


PROGRAM:
#include<stdio.h>
main()
{
int n,k;
printf("enter the value of n");
scanf("%d",&n);
pas(n);
if(k==n)
printf("it is a prime number");
else
printf("it is not a prime number");
}
pas(n)
{
int n,k;
int i=1;
{
while(i<=n)
{
if(n%i==0)
i++;
k++;
}
}
}

OUTPUT:
enter the value of n
7
it is a prime number
enter the value of n
6
it is not a prime number

No comments:

Post a Comment