C program to check prime number or not

List of programs below: c program to check prime number or not using functions, c program to check prime number or not using for loop, c program to check prime number or not using while loop, c program to check prime number or not using switch operator, c program to find prime numbers below n, c program to find prime numbers between  two given numbers, c program to find prime numbers between 1 and 100.

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. eg: 3 is prime number since it it has no factors other than 1 and 3
6 is not a prime since it has factors 2 & 3 other than 1 & 6

C program to check prime number or not using functions for while loop
C program to check prime number or not using functions, for loop, while loop

write a c program to check prime number or not using functions

write a c program to check prime number or not using functions

#include<stdio.h>
void main()
{
int n;
printf(” OUTPUT : c program to check a given number is prime or not using functions \n \n” );
printf(” \n enter the no.” );
scanf(“%d”, &n)
void findprime(n);
}

findprime(int num)
{
int i;
boolen temp = 1;
for (i=2; i<num; i++)
{
if (num%i==0)
{
temp=0;
break;
}
temp=1;
}
if (temp==1)
printf(” \n Yes, this is a prime number “);
else
printf(” \n No, this is not a prime number “);
}

OUTPUT : c program to check prime number or not using functions
OUTPUT : c program to check prime number or not using functions

write a C program to check prime number or not using for loop

write a c program to check prime number or not using for loop

#include<stdio.h>
void main()
{
int n,i, temp=1;
printf(” OUTPUT: c program to find whether a given number is prime or not using for loop \n \n” );
printf(” \n enter the no.:” );
scanf(“%d”, &n)
for (i=2; i<n; i++)
{
if (n%i==0)
{
temp=0;
break;
}
temp=1;
}
if (temp==1)
printf(” \n Yes, this is a prime number”);
else
printf(” \n No, this is not a prime number “);
}

OUTPUT : c program to check prime number or not using for loop
OUTPUT : c program to check prime number or not using for loop

write a c program to check prime number or not using while loop

write a c program to check prime number or not using while loop

#include<stdio.h>
void main()
{
int num,i=2, temp = 1;
printf(” OUTPUT: c program to find whether a given number is prime or not using while loop \n \n”);
printf(” \n enter the no:” );
scanf(“%d”, &num)
while( i<num )
{
if (num%i==0)
{
temp=0;
i++;
break;
}
temp=1;
}
if (temp ==1 )
printf(” \n Yes, this is a prime number”);
else
printf(” \n No, this is not a prime number “);
}

OUTPUT : c program to check prime number or not using while loop
OUTPUT : c program to check prime number or not using while loop

write a c program to find a number is prime or not using switch operator

write a c program to find a number is prime or not using switch operator

#include<stdio.h>
void main()
{
int n;
printf(“OUTPUT: c program to find whether a given number is prime or not using switch \n \n” );
printf(” \n enter no. \n” );
scanf(“%d”, &no)
for (i=2; i<no; i++)
{
if (no%i==0)
{
flag=0;
break;
}
flag=1;
}
switch (flag)
{
case 0:
printf(” \n Yes, this is a prime number”);
break;

case 1:
printf(” \n No, this is not a prime number “);
break;
}
}

OUTPUT : c program to check prime number or not using switch
OUTPUT : c program to check prime number or not using switch

write a c program to generate prime numbers below n

write a c program to generate prime numbers below n / write a c program to generate prime numbersless than n

#include<stdio.h>
void main()
{
int n;
printf(“OUTPUT: c program to generate prime numbers below n \n \n” );
printf(” \n enter no. \n” );
scanf(“%d”,& n)
for(int i=2;i<n;i++)
void findprime(i);
getch();
}

void findprime(int num)
{
int i;
for (i=2; i<num/2; i++)
{
if (num%i==0)
{
break;
}
printf(” \t  %d  “, num);
}
}

OUTPUT : c program to generate prime numbers below n
OUTPUT : c program to generate prime numbers less than  n

write a c program to find prime numbers between two given numbers

write a c program to find prime numbers between two given numbers

#include<stdio.h>
void main()
{
int n,m;
printf(“OUTPUT: c program to find prime numbers between two given numbers” );
printf(” \n enter first no. \n” );
scanf(“%d”, &n);
printf(” \n enter second no. \n” );
scanf(“%d”, &m)
if(n>m)
{
for (i=m;i<n;i++)
void findprime(i);
}
else
{
for (i=n;i<m;i++)
void findprime(i);
}
getch():
}

void findprime(int num)
{
int i;
for (i=2; i<num/2; i++)
{
if (num%i==0)
{
break;
}
printf(” \t  %d  “, num);
}
}

write a c program to find prime numbers between 1 and 100

write a c program to find prime numbers between 1 and 100

#include<stdio.h>
void main()
{
int i;
printf(“OUTPUT:c program to find prime numbers between 1 and 100″ );
// for c program to find prime numbers between 1 and 1000 use 1000 in place of 100
for (i=1;i<=100;i++)
void findprime(i);
getch():
}

void findprime(int num)
{
int i;
for (int i=2; i<num/2; i++)
{
if (num%i==0)
{
break;
}
printf(” \t  %d  “, num);
}
}

write a c program to check prime number or not using call by reference

write a c program to check prime number or not using call by reference

#include<stdio.h>
void main()
{
int *n;
printf(” OUTPUT : c program to check a given number is prime or not using call by reference \n \n” );
printf(” \n enter the no.” );
scanf(“%d”, n)
void findprime(*n);
}

findprime(int *num)
{
int i;
boolen temp = 1;
for (i=2; i<*num; i++)
{
if (*num%i==0)
{
temp=0;
break;
}
temp=1;
}
if (temp==1)
printf(” \n Yes, this is a prime number “);
else
printf(” \n No, this is not a prime number “);
}

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
decimal number to octal
convert decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

Leave a Reply

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