C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
30
1
2
using namespace std;3
4
int prime(int a);5
6
int main(){7
8
int number {};9
10
cout << "Enter a number that you want to check if it is prime or not : " ;11
cin >> number;12
13
prime(number);14
}15
16
int prime(int a){17
18
for (int i = 2; i < a ; i++)19
{20
if (a%i == 0)21
{22
cout << a << " is not a prime number." << endl;23
}else24
{25
cout << a << " is a prime number." << endl;26
}27
28
return 0; 29
}30
} $ g++ prog.cc -Wall -Wextra -std=c++11 -pedantic
Stdin
6Start
prog.cc: In function 'int prime(int)':
prog.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
30 | }
| ^
Enter a number that you want to check if it is prime or not : 6 is not a prime number.
0
Finish