Write a program in C to print all prime numbers from 1 to 300

Write a program in C to print all prime numbers from 1 to 300

          #include <stdio.h>
            #include <conio.h>
            void main() {
                        int i, j, temp, count;
                        clrscr();
                        for(i=1; i<=100; i++) {
                                    count=0;
                                    for(j=i; j>=1; j--) {
                                                temp=i%j;
                                                if(temp==0) {
                                                            count++;
                                                }
                                    }
                                    if(count==2) {
                                                
                                                printf("\n%d", i);
                                    }
                        }
                        getch();
            }



Post a Comment