C program to find the Sum of Prime numbers between a Range

Program to find the Sum of Prime numbers between a Range

Prime number is an Integer number. The Prime number can be divisable by 1 and the number itself. If a number has more positive divisors other than 1 and the number itself, then the number is not Prime number. For example: 2, 3, 5, 7, 11, 13, 17  . . . are Prime numbers. The below given C program to find the Sum of Prime numbers between a Range. Kindly check out the program to find the Sum of prime numbers between a Range.


Program to find Sum of prime numbers between Range


#include<stdio.h>

int main(){

    int numbr,k,remark,first,last,sum=0;

    printf("Give the First Number for the Range : ");
    scanf("%d",&first);
    printf("\n Give the Last Number for the Range : ");
    scanf("%d",&last);

    for(numbr= first; numbr<= last; ++numbr)

   {

    remark=0;

    for(k=2; k<=numbr/2; k++)

   {

        if((numbr % k) == 0){

        remark++;

        break;

        }

    }

   if(remark==0)

   sum += numbr;

   }

   printf("\n   Sum of prime numbers is:  %d ",sum);

   return 0;

}

 


Sample output:

Give the First Number for the Range :  20

Give the Last Number for the Range  :  100

 

Sum of prime numbers is:  983


Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share