Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Tuesday, January 4, 2011

Write a C Program to generate Prime Number from 10 to 50


Source Code :

#include<stdio.h>
void main()
{
      int n=10,i,j,fl=0;            //Declaration of variables
      clrscr();
      printf("\nThe Prime Numbers between 10 to 50 :")
      for(i=n;i<=50;i++)      //For Loop Iteration from 10 to 50 times
      {

            fl=0;
            for(j=2;j<i;j++)  //For Loop for checking prime number
            {
                  if(i%j==0)  //Checking if the number can be divided
                  {                       //by any other number other
                        fl=1;
                  }
            }
            if(fl==0)               //Checking for result
                  printf("%d ",i);        //Display the number
      }
      printf(“\nPress any Key to Continue………”);
      getch();
}

Output :

The Prime Numbers between 10 to 50 : 11  13  17  19  23  29  31  37  41  43  47

Press any Key to Continue..……..

1 comment:

  1. hi, its good program. I dint see the others program which does not maintain the indentation it look odd to look at such program without indentation.

    ReplyDelete