Program to check whether given Integer is Prime or Not

Description

Sample Input:
11
Sample Output:
11 is a Prime Number

Sample Input:
12
Sample Output:
12 isnot  a Prime Number

Solution

#include <stdio.h>
int main()
{
    int number, i;

    printf("Enter a Number: ");
    scanf("%d",&number);

    for(i=2; i<=number/2; ++i)
    {
       
        if(number%i==0)
        {
            printf("%d is not a prime number.",number);
            return 0;
        }
    }


    printf("%d is a prime number.",number);
             
    return 0;
}

Explanation

refer video tutorial



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution