0 LIKES LikeUnLike
You have to accept a number from the user and check whether its a prime number or not. Or you can also calculate the number of Prime numbers between 1 to 100
Tags:
#include<conio.h> main() { int n; int i,j,s=0; printf(" enter the upper limit from the set of even number "); scanf("%d",&n); { for(i=1;i<=n;i++)
{ for(j=2;j<=i/2;j++) { if(i%j==0) {
break; }}
if(i%j!=0) { s=s+i;
} } printf("suum of the prime number is=%d",s); } }
prime and their sum
Report (0) (0) | earlier
Write a program that calculates the sum of the digits of an integer. For example, the sum of the digits of the number 2155 is 2 + 1 + 5 + 5 or 13.The program should accept any arbitrary integer typed in by the user.
write a program that print the prime numbers between 1 and 100?
voidmain()
{
int i,n;
printf("enter the number to be checked");
scanf("%d",&n);
for(i=2;i<=n;i++)
if(n%i==0)
printf("number is not a prime number");
}
else
printf("given number is not a prime number");
getch();
/*Write a program to find the prime numbers and perfect numbers between 1 to 100 and also find how many prime numbers are there */
#include<stdio.h> #include<conio.h> void main() { int i,j,k,m,l,s,t; clrscr(); m=0; printf("\nThe prime numers are=\n"); for(i=1;i<=32765;i++) { k=0; for(j=1;j<=i;j++) { if(i%j==0) { k++; } } if(k==2) { printf(",%d",i); m++; } } printf("\n\nThe number of prime numbers are=%d",m); printf("\nthe perfect numbers are="); for(l=1;l<=32765;l++) { s=0; for(t=1;t<l;t++) { if(l%t==0) { s=s+t; } } if(l==s) { printf(",%d",s); } } getch(); }
Antareen.
polidrome number
#include<stdio.h> #include<conio.h> void main() { int n,i,p=1; clrscr(); printf("enter a number\n"); scanf("%d",&n);for(i=2;i<=n;i++) { if(n%2==0) p=0; break; } } if(p==1) { printf("prime number"); } else { printf("not a prime number"); } getch(); }
#include <stdio.h>
void main() { int i,j,n=100,count=0; for (i=2;i<n ;i++ ) { for (j=2;j<n/2 ;j++ ) { if (i%j == 0) { count++; } } if (count>1) { count=0; } else printf("\n %d",i); } }
#include<stdio.h>
void main ()
int n,i;
printf("enter any no.");
for("i=2 ,i < n, i++")
{ scanf("%d",&n);
if (n%i==0)
printf("no.is composite")
printf("no is prime")
#include<conio.h>
void main()
clrscr();
printf("Enter the number to be checked");
printf("the number is not prime");
break;
printf("the number is prime");
} }
int i;
if(i%2==0)
printf("The Entered Numbred is Prime");
printf("The Entered Number is Not Prime");
/*Programm by rana.................*/
Latest activity: earlier. This question has 21 answers.