Monday, April 1, 2013

Write a C program to check whether a given number is prime or ...

C program to find prime numbers



#include<stdio.h>

int main(){

    int num,i,count=0;
    printf("Enter a number: ");
    scanf("%d",&num);
    for(i=2;i<=num/2;i++){
        if(num%i==0){
         count++;
            break;
        }
    }
   if(count==0 && num!= 1)
        printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);
   return 0;
}

output:
Enter a number: 11
11 is a prime number
-----------------------------------------------
Write a C++ program to find prime numbers between  answers .Write a C Program to check number is Prime number . How can you write a program that will determine if the.Program to print first n prime numbers in c.?
C program to determine prime number. Determining if a number is prime in c. C program to find given number is prime or not

3 comments:

  1. You have a wonderful site. Excellent blog post! Isn’t it a wonderful feeling to share to others what we have learned? Keep on sharing. :)

    www.n8fan.net

    ReplyDelete
  2. It is great to have the opportunity to read a good quality article with useful information on topics that plenty are interested on.

    www.imarksweb.org

    ReplyDelete