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

  • Home
  • SEARCH
  • 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 6149813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:30:59+00:00 2026-05-23T19:30:59+00:00

I seem to have a problem with declarations screwing up my math. Any advice

  • 0

I seem to have a problem with declarations screwing up my math. Any advice or suggestions are highly welcomed.

Here’s the code:

int num1, num2, num3, num4, op, ;
    op = ((1==num3) || (2==num4)); 
    num3 = (num1 + num2);
    num4 = (num1 * num2);

I’ve been trying lots of arrangements and re-assignments. A lot has compiled, but when 5 + 5 = 2659043, there’s a problem…

  • 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-23T19:31:00+00:00Added an answer on May 23, 2026 at 7:31 pm

    Not sure what you’re trying to do, but this is what your code is doing:

    int num1, num2, num3, num4, op, ;
    

    This line informs the C compiler that it needs to allocate space for 5 integers (num1, num2, num3, num4, op), these integers can now be used as variables until the scope expires. Not sure why you have the last ‘,’ you might want to remove that.

    op = ((1==num3) || (2==num4)); 
    

    If num3 is 1, or num4 = 2, then set op to 1 (true). Otherwise, set op to 0 (false).

    num3 = (num1 + num2);
    

    Self-explanatory: Add num1 and num2 and put the sum into num3.

    num4 = (num1 * num2);
    

    Self explanatory: Multiply num1 and num2 and put the product into num4.

    Immediately I see an issue with your program. You are using these variables, but have not initialized them to anything. For example, how is there supposed to be a sum of (num1 + num2) if num1 and num2 do not have a value. Try this:

    #include <stdio.h>
    
    int main()
    {
       int num1, num2, sum;
       num1 = 1;
       num2 = 2;
       sum = num1 + num2;
    
       printf("sum = %d\n", sum);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I actually seem to have problem with this (only on linux, described here with
I seem to have a problem with this SQL query: SELECT * FROM appts
I seem to have a problem with getting MVC to fill in my custom
I seem to have a problem understanding how to conditionally test a boolean value
I have a problem which I cant seem to find answer to through searches
I have a problem, which I do not seem to be able to solve...
I seem to have the exact opposite problem than this question on stopping dock
I've run into an Objective-C problem that doesn't seem to make any sense to
Seem to have a problem starting my Java app: Exception in thread main java.lang.NoClassDefFoundError:
I seem to have a problem that I can't find the solution for myself,

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.