none
Need help with the a C# program

    Question

  • For some reason my program will not compute the square feet or square meters.  Any idea why this is happening.  michelleshockley7@hotmail.com

     

    #include <stdio.h>

    int main()

    {

    /* Vaible declarations */

    int cv_factor=36*36; /* Conversion factor to convert */

    int length_yds; /* Length in yards; input by user */

    int width_yds; /* Width in yards; input by user */

    int area_in_yards;

    int area_in_feet;

    int square_yards;

    int square_feet;

    int square_inches;

    int square_meters;

    int area_in_inches;

    int feet_cv_factor=3*3; /* Conversion factor to convert */

    /* Accept user input for length and width of lawn in yards */

    printf("input length and width of lawn in yards ");

    scanf("%d%d", &length_yds, &width_yds);

    /* Compute area of lawn in square yards, square feet, square inches and square meters */

    area_in_yards= (length_yds * width_yds);

    area_in_feet= (area_in_yards * feet_cv_factor);

    square_inches= (area_in_yards * cv_factor);

    square_feet= (area_in_yards * .007);

    square_meters= (square_feet/10.76);

    printf("\Lawn in square yards = %d\n", area_in_yards);

    printf("Lawn in square feet = %lf\n", square_feet);

    printf("\Lawn in square inches = %d\n", square_inches);

    printf("\Lawn in square meters = %lf\n", square_meters);

    return 0;

    }

    Wednesday, April 12, 2006 9:49 PM

Answers

  • Hi

    this type of programming is borland C/C++ not C#,

    try and change your declarations to double not int. also use #include<iostream.h>

    Thursday, April 13, 2006 7:02 AM

All replies

  • Need Help with a C# Program? Where is it?
    Wednesday, April 12, 2006 10:12 PM
  • calculations are happenning .. you are just losing them due to conversions.

    This looks like homework so I will point you in the right direction instead of giving you the answer ... If precision is being lost due to using the int data type ... what might help you keep from losing the precision? Hint: the int data type only holds whole numbers.

     

    Also this is C code not C# :) (as was already pointed out).

     

     

    Thursday, April 13, 2006 4:12 AM
  • Hi

    this type of programming is borland C/C++ not C#,

    try and change your declarations to double not int. also use #include<iostream.h>

    Thursday, April 13, 2006 7:02 AM