My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Programming

Programming Programming Languages, Interpreters, and Compilers - Assembly, Declarative, Machine, Object Oriented, Iterative


Reply
 
LinkBack Thread Tools Display Modes
August 6th, 2009, 03:28 PM   #1
 
Joined: Dec 2007
Posts: 187
Fix the errors

Fix any errors found in the following C++ source code. This source code outputs the area of a circle when a user inputs the value of radius.
Code:
#include <<iostream>>
using the namespace std:

int main
{
  const double PI = 3.14159;

  // Step 1: Read in radius.
  double radius = 20

  // Step 2: Compute the area of the circle.
  double area = radius * radius * PI;

  // Step 3: Display the area.
  cout << "The area is ";
  cout << area << endl;

  return 0;
}
johnny is offline  
 

My Computer Forum is free to register and we welcome everyone!

October 25th, 2009, 11:39 PM   #2
 
Joined: Mar 2009
Posts: 3
Re: Fix the errors

Why do you demand so? Other than the fact that you're not reading anything in... make your main void and get rid of that silly return statement! Sheesh!
Wetmelon is offline  
October 26th, 2009, 12:15 AM   #3
 
Joined: Dec 2007
Posts: 187
I already know how to fix the errors . . . I've posted it so that other people can read it and discuss.
johnny is offline  
July 28th, 2010, 03:37 AM   #4
 
Joined: May 2010
Posts: 23
Re: Fix the errors

Code:
#include <iostream>
using the namespace std:

int main()
{
  double PI = 3.14159;

  // Step 1: Read in radius.
  double radius = 20

  // Step 2: Compute the area of the circle.
  double area = radius * radius * PI;

  // Step 3: Display the area.
  cout << "The area is ";
  cout << area << endl;

  return 0;
}
How is this one?
chetanbhasin is offline  
Reply

  My Computer Forum > Computer Science Forum > Programming

Tags
errors, fix



Thread Tools
Display Modes






Copyright © 2018 My Computer Forum Forum. All rights reserved.