Showing posts with label Prime Number. Show all posts
Showing posts with label Prime Number. Show all posts

PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C

How To PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C Program.


#include <math.h>
#include <stdio.h>
main()
{
  int i, j;
  i = 1;
  while ( i < 300 )
  {
            j = 2;
            while ( j < sqrt(i) )
            {
                        if ( i % j == 0 )
                                    break;
                        else
                        {
                                    ++j;
                                    continue;
                        }
            }
   if ( j > sqrt(i) )
            printf("%d\t", i);
    ++i;
  }
  return 0;
}

Check given number is prime number or not using c program.

How To Check given number is prime number or not using c program.


#include<stdio.h>
int main(){
    int num,i,count=0;
    printf("\nEnter a number:");
    scanf("%d",&num);
    for(i=2;i<=num/2;i++){
        if(num%i==0){
         count++;
            break;
        }
    }
   if(count==0)
        printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);
   return 0;

}

C Program to Check Prime Use Loop And Recursive

How to write a C Program to Check Prime Use Loop And Recursive in C Programming Language ?


Solution For C Program :
/*Check Prime Use Loop And Recursive*/

C or C++ program to print prime number

How to write a C Program to print Prime Number From a Given Value (50) in C Programming Language ?


Solution For C Program: