Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4591162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:21:19+00:00 2026-05-21T22:21:19+00:00

I am making a collection of math functions. I used if statements to create

  • 0

I am making a collection of math functions. I used if statements to create error messages and cut down on user errors.. I don’t think I did it right.

string error_0;
string error_i;

if (num1 == 0;) {error_0 = "You cannot divide by zero. Fail."}
    else {error_0 = "";}

if (num1=<0;) {error_i = "Sorry, can't do imaginary numbers."} //for sqroot function
    else {error_i = "";}

if (num2=<0;) {error_i = "Sorry, can't do imaginary numbers."}
    else {error_i = "";}

… this gives me the following error messages in code::blocks compiling.

  • expected “)” before “;” token (the if lines)
  • expected primary expression before “)” token (the if lines)
  • else without a previous if (just for the last else)

I’m really new at C++ and from the examples I have everything looks correct. Help would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:21:19+00:00Added an answer on May 21, 2026 at 10:21 pm

    You need a semicolon after your strings and don’t need one inside the if conditions.
    Also, the operator is <=, not =<.

    string error_0;
    string error_i;
    
    if (num1 == 0) {error_0 = "You cannot divide by zero. Fail.";}
        else {error_0 = "";}
    
    if (num1 <= 0) {error_i = "Sorry, can't do imaginary numbers.";} //for sqroot function
        else {error_i = "";}
    
    if (num2 <= 0) {error_i = "Sorry, can't do imaginary numbers.";}
        else {error_i = "";}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a small collection of types/functions related to gradients for future use. I
I have a paginated collection that could be simultaneously making multiple fetch()es. E.G. a
I am looking for what most people use as their collection type when making
Okay, so I'm making a dynamic 2D array in Java that implements the java.util.Collection
wpdb class in wordpress is used for making connection to database. is there any
I have an issue. I am making an extension class for a Collection and
I'm planning on making my (family) photo collection available online. I want to use
I'd like to rank a collection of landscape images by making a game whereby
Just making a little android app, and I need to hold a collection of
I'm making a document-based Cocoa app in which the document is dynamic a collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.