Write C Program to find sum of all prime numbers between 1 to n -99webcode
#include <stdio.h>
int main()
{
int n ,i ,j , sum;
printf("enter a number");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
for(j=2;j<=n;j++)
{
if(i%j==0)
break;
}
if(i==j)
{
printf("%d ",i);
sum=sum+i;
}
}
printf("\n sum is prime no between %d is %d",n,sum);
}
enter a number 25
2 3 5 7 11 13 17 19 23
sum of prime no between 25 is 100