Write a program in C to find greatest prime number less than a given positive number.
#include<stdio.h>#include<conio.h>voidmain(){inti,n,n1,p,m=0;clrscr();printf("Enter a no:-");scanf("%d",&n1);for(n=1;n<=n1;n++){for(p=1,i=2;i<n;i++){if(n%i==0){p=0;break;}}if(p==1)m=0;if(p>m)m=n;}printf("\n%d is greatest prime no..",m);getch();}
0 Comments