#include<stdio.h> #include<conio.h> int main() { int i, j, count=0, arr[20], k=0; printf("\t\tBetween 1 to 20:\n\n"); printf("Prime Numbers: "); for(i=1; i<=20; i++) { for(j=2; j<i; j++) { if(i%j == 0) { count++; break; } } if(count==0) printf("%d ", i); else { arr[k] = i; k++; } count=0; } printf("\nComposite Numbers: "); for(i=0; i<k; i++) printf("%d ", arr[i]); getch(); return 0; }
C program to print prime and composite numbers between 1 to 20.
Reviewed by
on
December 22, 2019
Rating:
No comments: