Created
June 26, 2014 14:46
-
-
Save caseyamcl/d096a1ee75cf02003e5b to your computer and use it in GitHub Desktop.
Simple C Program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int n, i = 3, count, c; | |
printf("Enter the number of prime numbers required\n"); | |
scanf("%d",&n); | |
if ( n >= 1 ) | |
{ | |
printf("First %d prime numbers are :\n",n); | |
printf("2\n"); | |
} | |
for ( count = 2 ; count <= n ; ) | |
{ | |
for ( c = 2 ; c <= i - 1 ; c++ ) | |
{ | |
if ( i%c == 0 ) | |
break; | |
} | |
if ( c == i ) | |
{ | |
printf("%d\n",i); | |
count++; | |
} | |
i++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment