Friday, 11 August 2017

Assignment 1 : Group A

Assignment 1 : Group A
Aim:"Write a C program to check whether a input number is prime or not."



Theory : A Prime Number can be divided evenly only by 1, or itself. 
And it must be a whole number greater than 1.

Example: 5 can only be divided evenly by 1 or 5, so it is a prime number.

But 6 can be divided evenly by 1, 2, 3 and 6 so it is NOT a prime number (it is a composite number).



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



24 comments:

  1. FE Div:A,Batch:-A3
    Roll no.41

    ReplyDelete
    Replies
    1. good, implement the program in Practical session

      Delete
  2. Good very nice teaching prathmesh patil A2 batch 30 roll no

    ReplyDelete
  3. Well Understanding ....And Having Best Teaching A2 Batch
    Roll No-22

    ReplyDelete
  4. nice teaching by projector.... totally understood....

    ReplyDelete
  5. Good. Understood A2. Batch 17 rollno

    ReplyDelete
  6. Understood
    Nice. a2 batch roll no. 21

    ReplyDelete
  7. Nice one easy to understand

    ReplyDelete
  8. Nice one easy to understand
    FE(A)
    Roll no 35

    ReplyDelete
  9. good understood div-A Roll no.28 batch A2

    ReplyDelete