int main() { int a; printf("Enter the max number upto which you have to list all prime number: "); scanf("%d", &a); for (int i = 1; i <= a; i++) { for (int j = 2; j <= (i - 1); j++) { if ((i % 2) != 0) { printf("%d \n", i); break; } } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter