Use of Break(); in program.
Program to find whether the number is prime or not...
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t=0;
clrscr();
printf("Enter the number: ");
scanf("%d",&n);
for(i=2;i<n/2+1;i++)
{
if(n%i==0)
{
printf("Not prime");
t=1;
break;
}
}
if(t==0)
printf("The number is prime.");
getch();
}
Program to find whether the number is prime or not...
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t=0;
clrscr();
printf("Enter the number: ");
scanf("%d",&n);
for(i=2;i<n/2+1;i++)
{
if(n%i==0)
{
printf("Not prime");
t=1;
break;
}
}
if(t==0)
printf("The number is prime.");
getch();
}
No comments:
Post a Comment