#include<stdio.h>
      int main()
      {
          printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
          int n,i = 3, count, c;
          printf("\nEnter the number of prime numbers required :  ");
          scanf("%d", &n);
          if(n >= 1)
          {
              printf("\n\nFirst %d prime numbers are :  ", n);
              printf("2 ");
          }
          // iteration for n prime numbers
          // i is the number to be checked in each iteration starting from 3
          for(count = 2; count <= n; i++)  
          {
              // iteration to check c is prime or not
              for(c = 2; c < i; c++)
              {
                  if(i%c == 0)
                      break;
              }
              if(c == i)  // c is prime
              {
                  printf("%d ", i);
                  count++;    // increment the count of prime numbers
              }
          }
          printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n");
          return 0;
      }
      
      C language logo

      Prime Program

      0

      0

      avatar
      natalie19970

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.