Computer Science, asked by jrathorejyoti, 3 months ago

Write a C program to generate all the prime numbers between 1 and n, where n is a value

supplied by the user ?​

Answers

Answered by himanshu2006vps
14

Answer:

#include<stdio.h>

int main(){

int num,i,count,n;

printf("Enter max range: ");

scanf("%d",&n);

for(num = 1;num<=n;num++){

count = 0;

for(i=2;i<=num/2;i++){

if(num%i==0){

count++;

break;

}

}

if(count==0 && num!= 1)

printf("%d ",num);

}

return 0;

}

Similar questions