Program Prime Numbers C Language
Hey everyone, I want to share my experience with C language. This my program will print prime numbers. You simply enter the number of primes that you want to display. And this is the source code.
#include<stdio.h>
int main(){
int a, n, i, sum, total=0;
printf("input how prime should print : ");
scanf("%d",&n);
for(a=1;total<n;a++){
sum=0;
for(i=1;i<=a;i++){
if(a%i==0){
sum++;
}
}
if(sum==2){
printf("%d ",a);
total++;
}
}
}
It is a program from me, hopefully useful.

Comments
Post a Comment