Thread: Help needed.

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    Help needed.

    Hi guys could i get some help with this problem.
    Write a program to verify if the following expression is true.x^2 - y^2 = (x + y) * (x - y)The program will do the following:
    1. ask the user to enter the value of x and y;2. calculate the left member of the expression3. calculate the right member of the expression
    4. check if the two values are equal.


    This is what ive done so far but i dont know where to go from here.


    #include "stdio.h"
    void main () (
    int x= , int y=
    printf ("\n enter values of x and y\n");
    int sum1 = x*x-y*y;
    int sum2 = (x+y)*(x-y);
    scanf("%d", &sum1); // read sum1
    scanf("%d", $sum2); // read sum2
    if sum1==sum2;
    printf ("\n the two calues are equal \n");

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    First off, learn the right way to post code... POSTING CODE

    Code:
    #include "stdio.h"
    
    void main () 
      (
         int x= , int y=
         printf ("\n enter values of x and y\n");
         int sum1 = x*x-y*y;
         int sum2 = (x+y)*(x-y);
         scanf("%d", &sum1); // read sum1
         scanf("%d", $sum2); // read sum2
         if sum1==sum2;
          printf ("\n the two calues are equal \n);
    Now... you have errors on almost every line.

    Line 3 ... it's not void main() ... the correct form of main is...
    Code:
    int main (void)
    Line 4 ... you have a bracket to open the code section of the function. You need a curly brace there.
    Line 5 ... int x = , int y= ... is an incomplete stament that will return syntax errors from your compiler.
    Line 6 ... Grammar counts... Capitalize your displayed sentences.
    Lines 7 and 8 ... what are the values of x and y in these calculations?
    Lines 8 and 9 .... not only are your scanf() statements ill formed, you are actually inputting to the wrong variables.
    Line 10 ... you have no brackets around your conditional in the if() statement. And exactly what are you comparing?
    Line 11... Capitalization and spelling errors

    Also, you are missing the return value from main() (required by the operating system) and you have no closing brace for main()

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    13
    why did you put int x= and int y= ???

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help needed
    By golf in forum C Programming
    Replies: 1
    Last Post: 04-07-2008, 09:46 PM
  2. Help needed!!
    By jawahar in forum C++ Programming
    Replies: 4
    Last Post: 01-22-2008, 02:57 AM
  3. Help needed!
    By cherek in forum C++ Programming
    Replies: 2
    Last Post: 02-01-2006, 03:34 AM
  4. Web Bot Needed ( will pay ) Plz Look
    By tribalflames69 in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 05-04-2005, 11:37 AM
  5. Help needed
    By adrian_ang in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 02:49 AM