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 790011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:37:03+00:00 2026-05-14T21:37:03+00:00

Just as a practice, I am working on an app that solves the famous

  • 0

Just as a practice, I am working on an app that solves the famous middle school pythagorean theorem, a squared + b squared = c squared. Unfortunately, the out-coming answer has, in my eyes, nothing to do with the actual answer. Here is the code used during the “solve” action.

- (IBAction)solve {
 int legoneint;
 int legtwoint;
 int hypotenuseint;

 int lonesq = legoneint * legoneint;
 int ltwosq = legtwoint * legtwoint;
 int hyposq = hypotenuseint * hypotenuseint;

 hyposq = lonesq + ltwosq;

 if ([legone.text isEqual:@""]) {
  legtwoint = [legtwo.text intValue];
  hypotenuseint = [hypotenuse.text intValue];

  answer.text = [NSString stringWithFormat:@"%d", legoneint];
  self.view.backgroundColor = [UIColor blackColor];
 }
 if ([legtwo.text isEqual:@""]) {
  legoneint = [legone.text intValue];
  hypotenuseint = [hypotenuse.text intValue];

  answer.text = [NSString stringWithFormat:@"%d", legtwoint];
  self.view.backgroundColor = [UIColor blackColor];
 }
 if ([hypotenuse.text isEqual:@""]) {
  legoneint = [legone.text intValue];
  legtwoint = [legtwo.text intValue];

  answer.text = [NSString stringWithFormat:@"%d", hypotenuseint];
  self.view.backgroundColor = [UIColor blackColor];
 }
}

By the way, legone, legtwo, and hypotenuse all represent the UITextField that corresponds to each mathematical part of the right triangle. Answer is the UILabel that tells, you guessed it, the answer. Does anyone see any flaws in the program? Thanks in advance!

  • 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-14T21:37:03+00:00Added an answer on May 14, 2026 at 9:37 pm

    Did not checked the program carefully but in the first lines there is already a big problem:

    int lonesq = legoneint * legoneint;
    int ltwosq = legtwoint * legtwoint;
    int hyposq = hypotenuseint * hypotenuseint;
    

    This vars are defined using vars that are still not assigned at all. You need to set the value of the vars taken from the text fields, then do the math. C is a sequential language, everything is executed from top to bottom, you can’t say “a = bc” and a will be bc in any place of the program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering what people think is the best practice when implementing an IValueConverter which
Just a general question about what the best practice is: public void Foo() {
I'm just getting into the practice of version control (I'd like to use Eclipse
Just looking for the first step basic solution here that keeps the honest people
I am cleaning up some code in a C# app that I wrote and
I'm working in the Google App Engine environment and programming in Python. I am
I just got done working through the Django tutorials for the second time, and
In the iPhone app I'm currently working on, I'd like two view controllers (I'll
I am doing some analysis for a chunk of a desktop app we're working
Assume a typical, database and session driven ASP application developed using best practices just

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.