Thread: indentation error

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    15

    indentation error

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    
    void main(void)
    {
    	
    	//Declaration
    	double v_a,v_b,v_c,discriminant,root_1,root_2,sq_d;
    	
    	
    	//Input
    	printf("Enter a, b, c : ");
    	scanf("%lf %lf %lf",&v_a,&v_b,&v_c);
    	
    	
    	//Calculation
    	discriminant = (pow(v_b,2))-(4*v_a*v_c); 
    	sq_d = sqrt(discriminant);
    	root_1 = (-v_b+sq_d)/(2*v_a);
       	root_2 = (-v_b-sq_d)/(2*v_a);   
    	
    	
    	if (discriminant >= 0)
    	{
    		printf("\na=%f  b=%f  c=%f\n",v_a,v_b,v_c);
    		printf("\nThe roots are %.2f and %.2f\n",root_1,root_2);
    	}
    	else
    	{
    		printf("a=%f  b=%f  c=%f\nd = %f\n",v_a,v_b,v_c,discriminant);
    		printf("\nThe roots are complex.\n");
    	}
    	
    	exit(0);
    }   //End main
    The above program works fine but there is a INDENTATION ERROR when marking with online marking system......

  2. #2
    Registered User mitakeet's Avatar
    Join Date
    Jun 2005
    Location
    Maryland, USA
    Posts
    212
    If it ain't a compiler or run-time error, you ain't likely to get much help here!

    Free code: http://sol-biotech.com/code/.

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by cc870
    The above program works fine...
    Really? Might want to watch for a user input error causing a divide by 0.
    Code:
    scanf("%lf %lf %lf",&v_a,&v_b,&v_c);  //suppose I enter 0 first
    //v_a = 0
    <snip>
    root_1 = (-v_b+sq_d)/(2*v_a); //numerator/(2*0) = no good
    Quote Originally Posted by cc870
    ...INDENTATION ERROR when marking with online marking system.
    Cboard has an online marking system? I have to wonder what exactly you're talking about.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > void main(void)
    Indentation is the least of your problems.
    main returns int - read the FAQ

    > INDENTATION ERROR
    Sure - you go read the spec for the problem and find out what precise sequence of spaces, newlines and tabs will generate the "right answer"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM