ok first off, im extremely new to C++. taking my first c++ class. i have to write a program, which ive done, but i keep getting the same 5 errors over and over again and i cannot for the life of me figure out why. if anyone could help me it would be greatly appreciated!!
Thanks much all
Justin
program......
// Circle.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
int main ()
{
int R, D; //R is equal to Radius and D is to Diameter
float PI = 3.14159f; //pi is the variable representing Pi
std::cout << "Enter the radius of a circle"; >> // prompts user to input radius
std::cin << "radius"; >> //inputs radius
// calculations are listed below
D = 2*R
C = D*pi
A = R*R*pi
Check your semicolons. You have them placed in the middle of your cout statements. Also your mixing the stream insertion << and extraction >> operators.
ok, i fixed the <<<>> errors. ive got them all flipped to << "text" << . however (and again i appologize for being so new to all this and not knowing), but it seems the semi-colons have to be there in order for them to function right. without them, the program dislikes me, even more than it did to begin with! lol
program......
// Circle.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
int main ()
{
int R, D; //R is equal to Radius and D is to Diameter
float PI = 3.14159f; //pi is the variable representing Pi
std::cout << "Enter the radius of a circle"; >> // prompts user to input radius
std::cin << "radius"; >> //inputs radius
// calculations are listed below
D = 2*R
C = D*pi
A = R*R*pi
// results display as...
std::cout << "Diameter is"; << diameter << std::endl;
std::cout << "Circumference is"; << fixed << setprecision(4) << circumference << std::endl;
std::cout << "Area is"; << fixed << setprecision(2) << area << std::endl;
You had too many syntax errors , i just wrote out a corrected version of your code
so review this and compare the syntax of both source codes
#include <iostream>
#include <iomanip>
#include <limits> // Only used for keeping window alive
usingnamespace std; // easier then sprinkling std::'s everywhere
int main()
{
double C,R,D,A; // You want doubles for these operations, not ints
constdouble PI = 3.14159;
cout<<"Enter Radius of Cicle"<<endl
<<"Radius :";
cin>>R;
//Operations
D = R*2;
C = D*PI;
A = (R*R)*PI;
//Prompt
cout<<"Diameter is "<<D<<endl;
cout<<"Circumference is "<<fixed<<setprecision(4)<<C<<endl;
cout<<"Area is "<<fixed<<setprecision(2)<<A<<endl;
// Keeps Window Open
cout<<"Press Enter to Quit ...";
cin.sync();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
return 0;
}