Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

prime(x) is a function that returns true if x is a prime number and false otherwise, At the end of the loop?

0 votes
asked Feb 20, 2018 by anonymous

 //In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a //prime number and false otherwise.At the end of the loop?

i := 0; j := 0; k := 0;
for (m := start; m <= end; m := m+1){
  k := k + m;
  if (prime(m)){
    i := i + m;
  }else{
    j := j + m;
  }
}

2 Answers

0 votes
answered Feb 20, 2018 by 4
#include<stdio.h>

void prime(int x)

{

int i,c=0;

if(i=2;i<n;i++)

{

c=c+1;

break;

}

if(c==2)

{

printf("%d is a prime number:",x);

}

else

{

printf("%d not a prime number:",x);

}

}

int main()

{

int n,i;

printf("enter the number:");

scanf("%d",&n);

prime(n);

return 0;

}
0 votes
answered Jul 11, 2019 by anonymous
i+j=k is true at the end of the loop
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...