C Tutorial
This c program is used to find the prime numbers upto the user input limit.
A number greater than 1 is called a prime number, if it has exactly two factors, namely 1 and the number itself.
#include<stdio.h> void main() { int i, j, limit; int prime = 0; printf("Enter limit: "); scanf("%d", &limit); printf("Prime Numbers upto (%d): ", limit); for(i = 2;i <= limit;i++) { prime = 0; for(j = i-1; j > 1 ; j--) { if(i%j == 0) prime = 1; } if(prime == 0) printf("%d\t", i); } printf("\n"); }Output:
$ cc prime-numbers-list.c $ ./a.out Enter limit: 100 Prime Numbers upto (100): 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page