online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/*************************************************************** * Name: Prof. Rafael Orta * Course: Computer Science & Programming * Class: CS04103 Section: 1 & 2 * Assignment Date: 09/11/20 * File Name: Chapter3.cpp ***************************************************************** * ID: Chapter3 * Purpose: This program is used to ilustrated Chapter 3 concepts *****************************************************************/ #include <iostream> #include <string.h> #include <iomanip> #include <ctime> using namespace std; int main() { // Declaration Statements float age = 0, year = 0; string fName, equals, Test; short overUnder = 32767; double largeNumber = 9999999876543.2129; const int size = 11; char Cstr[size]; int num = 0; // Obtaining values from the keyboard using the cin command. cout << "Please write your first name and your age: "; cin >> fName >> age; cout << "Your First Name is " << fName << " and you are " << age << " years old." << endl; // Mathematical Expressions. year = 2020 - age; cout << "You were born around: " << year << endl; // Casting cout << "Floating point value casted to integer: " << static_cast<int>(4.2) << endl; // Overflow & Undeflow cout << "The Value of overUnder is: " << overUnder << endl; overUnder = overUnder + 1; cout << "The Value of overUnder creating an overflow is : " << overUnder << endl; overUnder = overUnder - 1; cout << "The Value of overUnder creating an underflow is : " << overUnder << endl; // Combined Assignment age += 10; cout << "In 10 years you will be " << age << " years old" << endl; // Stream manipulators cout << setw(49) << "Your First Name is: " << fName << endl; // Padding 49 character minus the size of the text here. cout << showpoint << "Your age in 10 years as a floating point value is: " << age << endl; age = age - 9.9742134; cout << "Your age as a floating point value is: " << age << endl; cout << setprecision(4) << "Your age with precision controlled is: " << age << endl; cout << "Displaying a large number: " << largeNumber << endl; cout << fixed << "Displaying a large number: " << largeNumber << endl; cout << scientific << "Displaying a large number: " << largeNumber << endl; // String Input cout << "Please write your full name again: "; cin >> fName; cout << "The command cin uses space as separator, therefore it stops when it sees the separation between first name and last name: " << fName << endl; cin.ignore(256,'\n'); cout << "Please write your full name once more: "; getline(cin,fName); cout << "You need to use the getline command for it: " << fName << endl; // String Functions equals.assign(80,'='); cout << equals << endl; cout << "Your name has: " << fName.length() << " characters." << endl; cout << "Your name is " << fName + " and you like the Eagles" << endl; // Using C-strings cout << equals << endl; cout << "Enter your cat's name: "; cin >> Cstr; strcpy(Cstr,"Manchego"); cout << "Your cat's name is : " << Cstr << endl; // A way of limiting the input length cout << "Enter 5 characters: " ; cin.width(5) ; cin >> Test; cout << endl << "Stored only: " << Test ; // Another way of limiting the input length cin.ignore(); cout << "\nEnter 5 characters once more: " ; cin >> setw(5) >> Test; cout << endl << "Stored only: " << Test ; // Using random numners cout << equals << endl; unsigned seed = time(0); srand(seed); num = rand() % 9; cout << "This is a random number from 1 to 10: " << num << endl; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue