Question:How to find prime numbers from 1 to 100 in c 

Answer 
#include<stdio.h>

int main(){
    int num,i,count;
  
    for(num = 1;num<=100;num++){
         count = 0;

         for(i=2;i<=num/2;i++){
             if(num%i==0){
                 count++;
                 break;
             }
        }
        
         if(count==0 && num!= 1)
             printf("%d ",num);
    }
  
   return 0;
}
Output: 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 

+ ExplanationNot Moderated
+ Report
Total Preview: 896
How to find prime numbers from 1 to 100 in c
Copyright © 2024. Powered by Intellect Software Ltd