BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

Write a C Program to generate n prime number by defining isprime () function

    
 /* Write a C Program to generate n prime number by defining isprime () function*/





    #include< stdio.h> 
    #include< conio.h>

   int isprime(int n){
        int m=0,i;
        m=n/2;    
           for(i=2;i<=m;i++)    
        {    
            if(n%i==0)    
            {    
           // printf("Number is not prime");    
            return 1;    
            }
        }    
            return 0;
        } 


    void main(){    
    int j,n,i,m=0,flag=0;    
    printf("PRINT N  prime number  from 1 to N:");    
    scanf("%d",&n);    
           

    for (j=0;j< n;j++){
     flag= isprime(j);
        if(flag==0)    
           printf("\n %d",j  );

    }
    getch();
   
     }