当前位置:网站首页>13. Write a program, in which a user-defined function is used to judge whether an integer is a prime number. The main function inputs a number and outputs whether it is a prime number.
13. Write a program, in which a user-defined function is used to judge whether an integer is a prime number. The main function inputs a number and outputs whether it is a prime number.
2022-07-24 05:07:00 【Cc++edge- Qi】
#include <math.h>
#include <stdio.h>
int IsPrimeNumber(int number)
{ int i;
if (number <= 1)
return 0;
for (i=2; i<sqrt(number); i++)
{ if ((number % i) == 0)
return 0; }
return 1;}
void main()
{ int n;
printf(“Please input n:”);
scanf(“%d”,&n);
if(IsPrimeNumber(n))
printf(“\n%d is a Prime Number”,n);
else printf(“\n%d is not a Prime Number”,n);}
边栏推荐
- Format problem handling
- Is it true to pay attention to official account and receive Xiaomi mobile power for free? Wechat circle of friends sends Xiaomi mobile power
- Transpose of array sparse matrix
- Several common sorts
- Middle aged crisis, workplace dad who dare not leave, how to face life's hesitation
- 几种常见的排序
- What if IPv4 has no internet access? Solutions to IPv4 without internet access rights (detailed explanation of pictures and texts)
- Accuracy of% connections. Now it is planned to meet the demand. The number of enterprises is enough
- The difference between run and start in thread class
- SHP building contour data restoration, 3D urban white film data production
猜你喜欢

Fiddler抓包工具的使用

想知道一个C程序是如何进行编译的吗?——带你认识程序的编译

Ren Xudong, chief open source liaison officer of Huawei: deeply cultivate basic software open source and jointly build the root technology of the digital world

Sort - quicksort

MGRE and OSPF comprehensive experiment

Zhaoyi innovation gd25wdxxk6 SPI nor flash product series comes out

Wang Qing, director of cloud infrastructure software research and development of Intel (China): Intel's technology development and prospects in cloud native

pso和mfpso

激活函数和最常用的10个激活函数

几种常见的排序
随机推荐
Chiitoitsu (expected DP)
What if the notepad file is too large to open? Introduction to the solution to the phenomenon that txt files are too large to be opened
power. The operation is in the low peak period of business. Import call will help you prepare each word
Mysq Database Constraints
Kingbase V8R6集群安装部署案例---脚本在线一键扩容
最大公约数
Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
Illustration and text demonstrate the movable range of the applet movable view
C. Recover an RBS (parenthesis sequence, thinking)
Activation functions and the 10 most commonly used activation functions
How to solve the engine prompt alias herodb and game engine startup exceptions?
Ben, reducing online importance is the same. Abnormal instance CP operation found
What is the proper resolution of the computer monitor? Introduction to the best resolution of monitors of various sizes and the selection of different wallpapers
How to make yourself look young in how old robot? How old do I look? Younger method skills
High performance architecture design of wechat circle of friends
Want to know how a C program is compiled—— Show you the compilation of the program
How to get the signature file of Baidu Post Bar? Baidu Post Bar signature file setting and use method graphic introduction
Zhaoyi innovation gd25wdxxk6 SPI nor flash product series comes out
What does the red five pointed star in the lower right corner of sina Weibo avatar mean? How to become a master of sina Weibo?
Event extraction and documentation (2020-2021)