C program to find prime number from 1 to 100 numbers using function

0
2
digitalample eye

Write a program to print prime numbers from 1 to 100 numbers.

Write a c program to find prime numbers using function.

C program to find prime number from 1 to 100 numbers using function

C Code

#include <stdio.h>
#include <conio.h>

int primenumber (int number);

void main()
{
int i;

printf("given numbers are prime numbers :n");

for(i =1; i<=100; i++)
{
if(primenumber(i))
printf("%dt",i);
}
getch();
}
int primenumber(int number){

int i, flag=1;

for(i=2; i<=number/2; i++){
if(number%i==0)
flag = 0;
}
return flag;
}

Output

LEAVE A REPLY

Please enter your comment!
Please enter your name here