Print the Composite numbers in an array.
#include<stdio.h>
int main() {
int a[10];
int i,j,c;
printf("Enter the elements of an array : \n");
for (i=0; i<10; i++){
scanf("%d",&a[i]);
}
for (i=0; i<10; i++){
c=0;
for (j=1; j<=a[i]; j++){
if (a[i]%j==0){
c++;
}
}
if (c>2){
printf("%d\t",a[i]);
}
}
return 0;
}
Output:-
Enter the elements of an array :
14 5 6 2 1 7 8 9 10 45
14 6 8 9 10 45
No comments:
Post a Comment