Q10. WAP to find a Input number is composite or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i, temp=1;
printf("Enter number: ");
scanf("%d",&n);
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
printf("%d is a composite number",n);
temp=0;
break;
}
}
if(temp==1)
printf("%d is NOT a composite number", n);
getch();
}
Output 1:
Enter number: 10
10 is a composite number
Output 2:
Enter number: 5
5 is NOT a composite number
Enter number: 10
10 is a composite number
Output 2:
Enter number: 5
5 is NOT a composite number