NO

Author Topic: I dont know what im doing wrong  (Read 3134 times)

dnasty54

  • Guest
I dont know what im doing wrong
« on: September 30, 2014, 02:16:33 AM »
/*
* calcute area of a rectangle.
*/
#include <stdio.h>               /* printf, scanf definitions */
#include <math.h>
int
main (void)
{
          double width,  /* input - width of rectangle. */
      double length, /* input - length of rectangle. */
      Area;    /* output - area of rectangle */

      /* get the width of rectangle. */
      printf("Enter width> ");
      scanf("%lf", &width);

      /* get the length of rectangle. */
      printf("Enter length> ");
      scanf("%lf", &length);

      /*convert to Area or rectangle. */
      Area  = width * length;
      
      /* display Area of rectangle. */
      printf( "The Area is %f . \n",  Area);

      return (0);

C:\Users\student\Documents\area.c(10): error #2092: Missing identifier.
C:\Users\student\Documents\area.c(10): error #2001: Syntax error; found 'double' expecting ';'.
*** Error code: 1 ***

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: I dont know what im doing wrong
« Reply #1 on: September 30, 2014, 02:28:34 AM »
Code: [Select]
/*
* calcute area of a rectangle.
*/
#include <stdio.h>               /* printf, scanf definitions */
#include <math.h>
int
main (void)
{
       double width,  /* input - width of rectangle. */
double length, /* input - length of rectangle. */
Area;    /* output - area of rectangle */
C:\Users\student\Documents\area.c(10): error #2092: Missing identifier.
C:\Users\student\Documents\area.c(10): error #2001: Syntax error; found 'double' expecting ';'.
*** Error code: 1 ***
Well, just read the error messages, they point exactly to the problem, in particular the second one... :!:
Correctly the snippet would be written
Code: [Select]
       double width;  /* input - width of rectangle. */
double length; /* input - length of rectangle. */
double Area;    /* output - area of rectangle */
Punctuation to terminate statements matters!  ;)

Ralf

dnasty54

  • Guest
Re: I dont know what im doing wrong
« Reply #2 on: September 30, 2014, 02:41:22 AM »
now i have those same errors twice!!  :-[ :-[

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: I dont know what im doing wrong
« Reply #3 on: September 30, 2014, 02:45:08 AM »
now i have those same errors twice!!  :-[ :-[
Post your complete code, surrounded by code tags, please...

Ralf

dnasty54

  • Guest
Re: I dont know what im doing wrong
« Reply #4 on: September 30, 2014, 02:49:07 AM »
nevermind i see what u were saying about the ;'s thanks alot!!

mtazy

  • Guest
Re: I dont know what im doing wrong
« Reply #5 on: October 02, 2014, 06:41:30 AM »
#include <stdio.h>
#include <math.h>
int main (void)
{
   double width;
   double length;
        double Area;

      /* get the width of rectangle. */
      printf("Enter width> ");
      scanf("%lf", &width);

      /* get the length of rectangle. */
      printf("Enter length> ");
      scanf("%lf", &length);

      /*convert to Area or rectangle. */
      Area  = width * length;
     
      /* display Area of rectangle. */
      printf( "The Area is %f . \n",  Area);

      return 0;
}

*make sure that when u open a brace, u close it after your 'return 0;'
*clearly read the errors, double-click each to see in which line the error is
*each instruction ends by a ';' not a ','