Interview Questions   Tutorials   Discussions   Programs   

C - Write a Program to display up to 100 prime numbers(without using Arrays, Pointer)?




318
views
asked marvit August 18, 2014 08:07 AM  

Write a Program to display up to 100 prime numbers(without using Arrays, Pointer)?


           

1 Answers



 
answered By bhjahnavi   0  

/*program to find prime number upto 100*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int num,n,div,p;
 printf("Enter any number: ");
 scanf("%d", &num);
 for(n=2; n<=num; n++)
 {
 for(div=2; div<n; div++)
 {
  if(n%div==0)
  {
   p=0;
   break;
  }
  p=1;
 }
 if(p)
  printf("\t%d",n);
 }
 
}
output: enter any number :100 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

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert