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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:54:16+00:00 2026-06-12T21:54:16+00:00

Compiler errors: pythagoras.c: In function ‘main’: pythagoras.c:22:4: fejl: ‘else’ without a previous ‘if’ pythagoras.c:29:5:

  • 0

Compiler errors:

pythagoras.c: In function ‘main’:
pythagoras.c:22:4: fejl: ‘else’ without a previous ‘if’
pythagoras.c:29:5: fejl: ‘else’ without a previous ‘if’

The code:

#include <stdio.h>
#include <math.h>
int main(void)
{
  double a, b, c;
  double secondside1, secondside2, secondside3;
char Scanres;
printf("Hvilken side vil du finde? a, b eller c?\n");
Scanres = scanf("%c", &Scanres);
secondside1 = a * a;
secondside2 = b * b;
secondside3 = c * c;

    if(Scanres = c);

    printf("Indtast værdierne af a og b\n");
    scanf("%lf%lf", &a, &b);
    c = sqrt(secondside1 + secondside2);
        printf("c er %f", c);

        else if(Scanres = b);

        printf("Indtast værdierne af a og c\n");
        scanf("%lf%lf", &a, &c);
        b = sqrt(secondside3 - secondside2);
        printf("b er %f\n", b);

            else(Scanres = a);

            printf("Indtast værdierne af b og c\n");
            scanf("%lf%lf", &b, &c);
            a = sqrt(secondside3 - secondside1);
            printf("a er %lf", a);
return 0;
}
  • 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-06-12T21:54:18+00:00Added an answer on June 12, 2026 at 9:54 pm

    The comparison operator in C is ==. With a single = you are doing assignment.

    Also, having a semicolon after the if() makes it execute an empty statement, rather than the code path you thought.

    Note that indentation is free in C, it carries no meaning so the compiler won’t warn you if it seems non-sensical.

    Further, this:

    Scanres = scanf("%c", &Scanres);
    

    doesn’t make a lot of sense. The scanf() function will write the character it read into Scanres, but then you will overwrite that value by storing the return value of scanf() (which is the number of conversions it made) into the same variable.

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

Sidebar

Related Questions

I get Compiler Error C2248 when i try to compile the following code: #include
Below code instantiates a derived singleton object based on environment variable. The compiler errors
Problem is as follow: The following test throws huge amounts of compiler errors. #include
Why do I get compiler errors with this Java code? 1 public List<? extends
I am getting the following compiler errors with the below code snippet: An object
I'm experiencing unexpected compiler errors with this code: bool b = true; //or false
The code below gives me three compiler errors. They are as follows: The type
Whenever I execute my C# code everything goes well, no compiler errors, nothing. But
My compiler errors are extremely long because g++ tells me the many 'candidates' for
I get compiler errors in : template<class _Other1, class _Other2> _Pair_base(_Other1&& _Val1, _Other2&& _Val2)

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.