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

I am looking at writing an ecommerce platform just for working practice and a
I'm just looking for best practice reassurance on working with jQuery and ASP.Net, before
I'm currently working on an iPhone app that requires the user to accept a
I've got in-app purchases working just fine, and I'm going the server validation route.
I have a rails app I am working on that allows users to create
I am working within a Ruby on Rails app. I have a loop that
I've just spent numerous hours constructing an icon for an Android app I'm working
currently, i am working on an app that uses Core Data. One of my
I am working on this app that accesses session variables in the model layer.
So this is the code I'm working on. Its just a practice and it's

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.