Notice: Function wpdb::prepare was called incorrectly. The query does not contain the correct number of placeholders (2) for the number of arguments passed (8). Please see Debugging in WordPress for more information. (This message was added in version 4.8.3.) in /home/programmershelp/public_html/wp-includes/functions.php on line 5835

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%i) AS last_modified, MIN(p.%i) AS published_at FROM %i AS p WHERE p....' at line 1]
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at FROM %i AS p WHERE p.%i IN ('post_modified_gmt') AND p.%i = '' AND p.%i = 0


Warning: Attempt to read property "published_at" on null in /home/programmershelp/public_html/wp-content/plugins/wordpress-seo/src/builders/indexable-author-builder.php on line 106

Warning: Attempt to read property "last_modified" on null in /home/programmershelp/public_html/wp-content/plugins/wordpress-seo/src/builders/indexable-author-builder.php on line 107
Check if the number is Positive or Negative in C++ - Programmers help
Home C++ Check if the number is Positive or Negative in C++

Check if the number is Positive or Negative in C++

In this example we will check if a number is positive or negative in C++

Example

We use an if -else statement in this example after taking input from the user

#include <iostream>
using namespace std;

int main()
{
    cout << "number is positive or negative\n\n";

    int myNumber;

    //taking user input
    cout << "Enter a non-zero Number: ";
    cin >> myNumber;

    //display output depending on result
    if (myNumber > 0)
    {
        cout << "\nEntered number is positive";
    }
    else
    {
        cout << "\nEntered number is negative";
    }

    cout << "\n";

    return 0;
}

When you run this you will see something like this

number is positive or negative

Enter a non-zero Number: 6

Entered number is positive
number is positive or negative

Enter a non-zero Number: -2

Entered number is negative

You may also like