//Program to display prime numbers between 1 to 100
#include<stdio.h>
#include<conio.h>
int main()
{
int n,j;
clrscr();
printf("Prime numbers between 1 to 100\n");
for(n=3;n<=100;n++)
{
for(j=2;j<=100;j++)
{
if(n%j==0)
break;
}
if(j==n)
printf("%4d",n);
}
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.
#include<stdio.h>
#include<conio.h>
int main()
{
int n,j;
clrscr();
printf("Prime numbers between 1 to 100\n");
for(n=3;n<=100;n++)
{
for(j=2;j<=100;j++)
{
if(n%j==0)
break;
}
if(j==n)
printf("%4d",n);
}
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.
It is not come output
ReplyDeletePrime number program in C
ReplyDeleteThanks for this post
it doesn't give output
ReplyDeleteIt won't give an output as they haven't printed it in the code
ReplyDeleteThey should write something like
printf("Number is prime\n");
It won't give an output as they haven't printed it in the code
ReplyDeleteThey should write something like
printf("Number is prime\n");
for(n=2;n<=100;n++) would also display 2.
ReplyDeletein printf(%4d,n) why 4 is there in between percent and d
ReplyDeletein printf(%4d,n) why 4 is there in between percent and d
ReplyDeleteTo suppress the result within for digits....u can just give ℅d too
Delete