Search
 
SCRIPT & CODE EXAMPLE
 

CPP

no argument but return value in c++

#include <iostream>
using namespace std;

void prime(int n);

int main()
{
    int num;
    cout << "Enter a positive integer to check: ";
    cin >> num;
    
    // Argument num is passed to the function prime()
    prime(num);
    return 0;
}

// There is no return value to calling function. Hence, return type of function is void. */
void prime(int n)
{
    int i, flag = 0;
    for (i = 2; i <= n/2; ++i)
    {
        if (n%i == 0)
        {
            flag = 1;
            break;
        }
    }

    if (flag == 1)
    {
        cout << n << " is not a prime number.";
    }
    else {
        cout << n << " is a prime number.";
    }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: 130 divided by -10 
Cpp :: c++ how to iterate through 2d array in c++ 
Cpp :: Studying Alphabet codechef solution in c++ 
Cpp :: how to convert malloc function to cpp 
Cpp :: c++ void to avoid functions 
Cpp :: compilling c++ and c by console 
Cpp :: C++ Dynamic allocation failing 
Cpp :: is plaindrome 
Cpp :: c++ to assembly 
Cpp :: how to define a node in c++ 
Cpp :: ue4 c++ oncomponentbeginoverlap 
Cpp :: Normal Initialisation of 3D Vector 
Cpp :: 12 to december in c++ code 
Cpp :: c++ union set q5 
Cpp :: font family slick 
Cpp :: Chef and Races codechef solution in c++ 
Cpp :: how to srt vector array 
Cpp :: c++ const shared_ptr 
Cpp :: template in cpp 
Cpp :: if c++ 
Cpp :: type casting in cpp 
Cpp :: how to create a structure c++ 
Cpp :: in c++ 
Cpp :: vector erase iterator 
Cpp :: qregexpvalidator qlineedit email address 
C :: how to store a user input with spaces in c 
C :: Donut-shaped C code 
C :: c code to python code converter online 
C :: multiplication table using c 
C :: C percentage program 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =