Sunday, 21 January 2018

Program for Prime Number


Program for Prime Number
#include<stdio.h>
#include<conio.h>
main()
{
int n,a,j,i,t=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
t=0;
for(i=2;i<=j-1;i++)
{
a=j%i;
if(a==0)
{
t=t+1;

}
}
if(t==0)
printf("%d\n",j);
}

getch();
}�

Related Posts:

  • Program for Even or Odd/*check even or odd*/#include<stdio.h>#include<conio.h>main(){ int a; clrscr(); printf("enter the value of a"); scanf("%d",&a); if(a%2==0) { printf("%d is even",a); } else printf("%d is odd",a); getch();} … Read More
  • Program for Compound Interest/*programme to cal compound intrest*/#include<stdio.h>#include<conio.h>#include<math.h>main(){ int p,r,n; float ci; printf("enter the values of p,r,n"); scanf("%d%d%d",&p,&r,&n); ci=p*(pow(((1+r)… Read More
  • Program for FIBANOCHI #include<stdio.h>#include<conio.h>main(){ int a,i=0,f0=0,f1=1,f; clrscr(); printf("enter the value of a"); scanf("%d",&a); printf("%d\n",f0); printf("%d\n",f1); do {       f=f0+f1; printf(… Read More
  • Program for Factorial /*factorial*/#include<stdio.h>#include<conio.h>main(){ int i,n,f=1; clrscr(); printf("enter the value of n"); scanf("%d",&n); for(i=1;i<=n;++i) { f=f*i; } printf("%d",f); getch();} … Read More
  • Program for Flyorid Traingle/*floyd triangle*/#include<stdio.h>#include<conio.h>main(){ int i,j,t=1,n; clrscr(); printf("enter the value of n"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("%3d",t); t=t+1; }… Read More

0 comments:

Post a Comment