Question:Write a c program to generate n prime numbers
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; }Sample output: Enter max range: 50 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
+ ExplanationNot Moderated
+ Report
Write a c program to generate n prime numbers