Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++, when I run the program and input a char or string value, the cout < < The number is zero < < endl;

in C++, when I run the program and input a char or string value, the cout << "The number is zero" << endl; line executes. Does the cin statement read a char or string value as zero? or how can i make the else statement execute when I input a string or char value?

int number,

cout << "This program will determine wether a number is negative, positive, or zero" << endl;

<< "Enter a number: ";

cin >> number;

if (number == 0)

cout << "The number is zero" << endl;

else if (number > 0)

cout << "The number is positive!" << endl;

else if (number < 0)

cout << "The number is negative!" << endl;

else

cout << "You were instructed to enter a number!" << endl; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions