ok so yesterday i had issues with devc++ (where my code occasionally compiled) and when i tried to run the "compiled" program it says "source not compiled" (when really..i hit the compile button).

So..i have now installed Visual c++ 2008, and i cant create a new project, it just says "Automation server cant create object!).

Then,....i move onto Code::Blocks C++ compiler; and i paste in the following from my previous devc++.

/*A program that calculates the area and the perimether of rectangular piece of land*/
#include <iostream.h>
typedef unsigned short int pint;
int main()
{
    pint width;
    pint length;
    pint area=(width*length);
    pint perM=( (width+width) + (length+length) );
    
    pint answer;
    
    cout<<"Enter the width of the land:\n";
    cin>> width;
    cout<<"Enter the length of the land:\n";
    cin>>length;
    
    cout<<"\nPress 1 to calculate the area 'or' Press 2 to calculate the perimeter\n";
    cin>> answer;
    
{
    if (answer == 1)
               {
               cout<<"The area of the land is:" << area << "m2";
               }
               
    if (answer == 2)
               {
               cout<<"The perimeter is:" << perM << "meters";
               }
    else
    {
        if (answer > 2)
        cout<<"I said press 1 or 2; not press some other random button!!!";
    }
}

so after pasting that i go build>"compile current file" on code::blocks
and then nothing happens!!!,

Im confused and i cannot even run my code (which....i spent 30mins doing, keep in mind im a newbie)

Any suggestions as to why all this is happening? and is there anything i can do? is my code correct?

(edit2:: the same problem from devc++ is in code::blocks now??!)

> pint area=(width*length);
> pint perM=( (width+width) + (length+length) );
How about moving these lines to AFTER you have input the values. Expressions are evaluated at the point you write them. They're not some kind of "rule" continually updated when new information (say cin >> width) happens.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.