Example: Add fun, which determines whether a number is prime. When the number is prime, the function returns the string “yes!” Otherwise the function returns the string “No!” And output it in the main function.

For example, enter 13 to return yes! ; Type 8 to return no! Do not change anything in main or the other functions. Only fill in the necessary expressions or statements along the lines of fun.

`The code is as follows:`

``````#include<conio.h>
#include<stdio.h>
char*fun(int m)
{
int i,j;
j=1;
for(i=2; i<m; i++)if(m%i==0)
{
j=0;
break;
}
if(j==1&&m>1)
return("yes!");
else
return("no!");
}
main()
{
int n=0;
scanf("%d",&n);
printf("%s\n",fun(n));
}
Copy the code``````

The output running window is as follows:

Other exercises this week

C programming column

① Please add fun function, this function is to determine whether a number is prime. When the number is prime, the function returns the string “yes!” Otherwise the function returns the string “No!” And output it in the main function.

(fun) (string s) (STR) (string S) (fun) (string S) (STR) (string S) (string S) (fun) (STR) (string S) (string S) (string S) (string S)

③ The function of the given program is to segment the scores of m individuals, test scores in the score array, the number of segments stored in the a array:

In the following given program, the function of fun is: given n real numbers, output average, and count the number of real numbers above average (including average).

Find the element whose value is a in s, return the number of elements whose value is a, and store the subscripts of these elements in sequence in array STR.

Use recursive algorithm to calculate the value of the NTH term in the Fibonacci series. From the first term, the Fibonacci series is 1, 1, 2, 3, 5, 8…

Fun moves all non-numeric characters in the string referred to by S after all numeric characters, and preserves the original sequence of numeric and non-numeric strings.

Fun computes and outputs the sum of the 10 largest primes up to Max. High passes from the main function to fun.

The harder you work, the luckier you get! Come on, Aoli!!