Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
No arguments passed and no return value In C++
SUBMITTED BY:
suru4dan
DATE:
May 23, 2017, 9:13 a.m.
FORMAT:
C++
SIZE:
645 Bytes
Raw
Download
Tweet
HITS:
440
Go to comments
Report
#
include
<iostream>
using
namespace
std
;
void
prime
();
int
main
()
{
// No argument is passed to prime()
prime
();
return
0
;
}
// Return type of function is void because value is not returned.
void
prime
()
{
int
num
,
i
,
flag
=
0
;
printf
(
"Enter a positive integer enter to check: "
);
cin
>>
num
;
for
(
i
=
2
;
i
<=
num
/
2
;
++
i
)
{
if
(
num
%
i
==
0
)
{
flag
=
1
;
break
;
}
}
if
(
flag
==
1
)
{
cout
<<
num
<<
" is not a prime number."
;
}
else
{
cout
<<
num
<<
" is a prime number."
;
}
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus