Using repl.it with C++

In this activity we will repl.it C++ programming Environment, and trying it on on a simple program. The goal is to make sure we understand the basic programming environment and tools.

Repl.itis an online web based IDE - an Integrated Development Environment. This means it is a tool for writing, testing, and managing programing activities. It can be used with a variety of languages (such a Python and Java), but we will be using it for the C++ programing language.

Set up repl.it

  1. Go to repl.it: https://repl.it/
  2. Create a Log in using your Kenyon email username

Start a new project

  1. Click the blue "+ new repl" button
  2. Select the "C++" option (not "C++ 11")
  3. Click "Create repl"
  4. Clink the little pencil beside in the upper right.
  5. Change the name to "MyFirstProgram"
  6. Click the switch from "Public" to "Private". THIS IS IMPORTANT!
  7. Hit enter or click outside the edit box.

Add code

  1. Click in the box label "main.cpp"
  2. copy and paste the following code:
//C++ program to find the Area and Perimeter of a Rectangle:

#include<iostream>
using namespace std;

int main()
{
    int width,height,area,perimeter;
    cout<<"Enter  Width of Rectangle = ";
    cin>>width;
    cout<<"Enter  Height of Rectangle = ";
    cin>>height;
    area=height*width;
    cout<<"Area of Rectangle ="<<area<<endl;
    perimeter=2*(height+width);
    cout<<" Perimeter of rectangle are = "<<perimeter<<endl;

    return 0;

}

-- Jim Skon - 2016-08-19

Run the Program

  • Hit the green run button (top center)
  • Program runs in the "output" window.

Make your own

  • Create a new program, call it "Triangle"
  • Paste the rectangle program into the main.cpp file
  • Modify to compute the area and perimeter of a triangle.
  • Remember: Area = 1/2(Base * height)

Comments



This topic: SCMP118/Fall2016 > WebHome > NotesDay1
Topic revision: r5 - 2019-08-28 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback