C Programming
C Programming

To check weather a number is Prime or Not

To check weather a number is Prime or Not

C programming

To check weather a number is Prime or Not

 

 

Question:

Write a C program to check weather a number is Prime or Not.

 

Solution:

 

#include<stdio.h>
int main(){
    int n;
    printf(“Enter a number:”);
    scanf(“%d”,&n);
    int prime=1;
    //1 means the number is Prime
    //0 means the number is Not Prime
    for(int i=2;i<n;i++){
        if(n%i==0){
            prime=0;
        }
    }
    prime==1 ? printf(“The number is Prime\n”) :printf(“The number is not Prime\n”);
    return 0;
}

Topics Covered :

  • check if number is prime
  • c program for prime number
  • prime number in c
  • prime number code in c
  • c programming for interview
  • prime number code
  • c programming for gate
  • gate c programming questions
  • c programming for beginners
  • gate computer science
  • c programs
  • prime number program in c
  • c programming
  • gate cse lectures
  • prime number program

 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

🧑‍💻🧑‍💻 Social Media Links of Tech DCode :

👉🏻 YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
👉🏻 Instagram : https://www.instagram.com/thetechdcode/
👉🏻 Facebook Page : https://www.facebook.com/thetechdcode
👉🏻 Twitter : https://twitter.com/thetechdcode
👉🏻 Telegram Channel : https://t.me/thetechdcode
👉🏻 Tech DCode Linktree : https://linktr.ee/thetechdcode
👉🏻 My Personal Handles : https://linktr.ee/virtualshivamin

🧑‍💻🧑‍💻 Social Media Links of SHIVAM SINGH (OWNER) :

👉🏻 Instagram : https://www.instagram.com/virtualshivamin/
👉🏻 Facebook Page : https://www.facebook.com/virtualshivamin/
👉🏻 Twitter : https://twitter.com/virtualshivamin/
👉🏻 Personal Linktree : https://linktr.ee/virtualshivamin 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *