- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int n,i,m=0,flag=0; //declaration of variables.
- clrscr(); //It clears the screen.
- printf(“Enter the number to check prime:”);
- scanf(“%d”,&n);
- m=n/2;
- for(i=2;i<=m;i++)
- {
- if(n%i==0)
- {
- printf(“Number is not prime”);
- flag=1;
- break; //break keyword used to terminate from the loop.
- }
- }
- if(flag==0)
- printf(“Number is prime”);
- getch(); //It reads a character from the keyword.
- }
Ashifa Asked question June 24, 2023
