Computer Science, asked by bhowmicksneha2005, 5 months ago

Write a program to input 10 numbers into an integer array and find the sum of the prime numbers only.​

Answers

Answered by puneetdevman
4

Answer:

Program defined and flowchart attached

Explanation:

This code is written in C program, but you can use your own logic given in the code.

#include <stdio.h>

#include <conio.h>

int main()

{

   int n, i, flag = 0;

   clrscr();

   printf("Enter a positive integer: ");

   scanf("%d",&n);

   for(i=2; i<=n/2; ++i)

   {

       // condition for nonprime number

       if(n%i==0)

       {

           flag=1;

           break;

       }

   }

   if (flag==0)

       printf("%d is a prime number.",n);

   else

printf("%d is not a prime number.",n);

   getch();

   

   return 0;

}

Attachments:
Similar questions