Thread: Getting error

  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    PlungÄ—, Lithuania
    Posts
    2

    Getting error

    Hello, im new in C++ and im getting annoying error. Maybe anyone could explain me where is the problem. Compiler shows that a problem is in a line 20 If (D<0).
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main ()
    {
        float a,b,c,D,x1,x2;
        printf ("Iveskite a kintamaji \n");
        scanf ("%f",a);
        printf ("Iveskite b kintamaji \n");
        scanf ("%f",b);
        printf ("Iveskite c kintamaji");
        scanf ("%f",c);
        if (a=0)
        {
        printf ("Lygtis ne kvadratine, niekas nebus apskaiciuota \n");
        system ("pause");
        return 0;
        }
         else
          D =(b*b) - (4*a*c);
        If (D<0)
         printf ("Sprendiniu nera \n");
        else 
        {
        x1= ((-1)*b-sqrt(D))/(2*a);
         x2= ((-1)*b+sqrt(D))/(2*a);
        Printf ("Atsakymai: %f, %f \n",x1,x2);
        system ("pause");
        return 0;
        }
    }
    Last edited by Valancius; 09-30-2012 at 07:58 AM.

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Replade If with if

    Also mind that in scanf function you should pass the address of the variable.Example
    Code:
    int i;
    scanf("%d",&i);
    Why?Because this is what the prototype of the function needs in order to maintain the modification made by input.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Location
    PlungÄ—, Lithuania
    Posts
    2
    Quote Originally Posted by std10093 View Post
    Replade If with if

    Also mind that in scanf function you should pass the address of the variable.Example
    Code:
    int i;
    scanf("%d",&i);
    Why?Because this is what the prototype of the function needs in order to maintain the modification made by input.
    O, thanks. Just missed

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This is C, not C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 4
    Last Post: 07-24-2011, 09:38 PM
  3. Replies: 1
    Last Post: 11-15-2010, 11:14 AM
  4. Replies: 3
    Last Post: 10-02-2007, 09:12 PM
  5. Compiler error error C2065: '_beginthreadex; : undeclared identifier
    By Roaring_Tiger in forum Windows Programming
    Replies: 3
    Last Post: 04-29-2003, 01:54 AM