Horje
prime numbers c Code Example
prime numbers c
#include<stdio.h>
void main()
{
    int num;
    int prime = 1;
    printf("Enter a number = ");
    scanf("%d",&num);


    for(int i = 2; i < num; i++)
    {
        if(num % i == 0)
        {
            prime = 0;
            break;
        }
    }
    if(prime == 1 && num>0 && num !=1)
    {
        printf("%d is a prime number.", num);
    }
    else
    {
        printf("%d isn't a prime number.", num);
    }
}
prime number in c
#include<stdio.h>
void main(){
    int num, i;
    int cp = 1;
    printf("Enter a number = ");
    scanf("%d",&num);

    if(num > 0){
        for(i = 2; i < num; i++){
            if(num % i == 0){
                cp = 0;
            }
        }
        if(cp == 1){
            printf("%d is a prime number.", num);
        }
        else{
            printf("%d isn't a prime number.", num);
        }
    }
}
prime number c program
int isPrime(int n) {
  for (int i = 2; i < n; i++) if (n % i == 0) return 0; 
  return 1;
}




C

Related
_CRT_SECURE_NO_WARNINGS Code Example _CRT_SECURE_NO_WARNINGS Code Example
ModuleNotFoundError: No module named 'tensorboardX' Code Example ModuleNotFoundError: No module named 'tensorboardX' Code Example
ImportError: No module named 'skimage' Code Example ImportError: No module named 'skimage' Code Example
how to slow voice speed in pyttsx3 Code Example how to slow voice speed in pyttsx3 Code Example
stop redis server Code Example stop redis server Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
25