Preview

C+++ Basic Lessons

Good Essays
Open Document
Open Document
711 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
C+++ Basic Lessons
I/O Library Header Files:
There are following header files important to C++ programs:
The standard output stream (cout):
The predefined object cout is an instance of ostream class. The cout object is said to be "connected to" the standard output device, which usually is the display screen. The cout is used in conjunction with the stream insertion operator, which is written as << which are two less than signs as shown in the following example.
-------------------------------------------------
#include <iostream>
-------------------------------------------------

------------------------------------------------- using namespace std;
-------------------------------------------------

------------------------------------------------- int main( )
-------------------------------------------------
{
-------------------------------------------------
char str[] = "Hello C++";
-------------------------------------------------

------------------------------------------------- cout << "Value of str is : " << str << endl;
-------------------------------------------------
}
When the above code is compiled and executed, it produces following result:
-------------------------------------------------
Value of str is : Hello C++
The C++ compiler also determines the data type of variable to be output and selects the appropriate stream insertion operator to display the value. The << operator is overloaded to output data items of built-in types integer, float, double, strings and pointer values.
The insertion operator << may be used more than once in a single statement as shown above andendl is used to add a new-line at the end of the line.
The standard input stream (cin):
The predefined object cin is an instance of istream class.

You May Also Find These Documents Helpful

  • Good Essays

    Declares > this is the statements that declare variables, constants, and other code elements, which can then be used within that block…

    • 193 Words
    • 1 Page
    Good Essays
  • Satisfactory Essays

    cout << "Select the operator you want to work (+ for addition, - for subtraction , * for multiplication , / for division):- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    4. AND operator- combines more than one condition in a program. Makes a compunf Boolean operation.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    C181 Course Study Guide

    • 2395 Words
    • 15 Pages

    2. What are the fundamental values of American democracy? How are these values show in the…

    • 2395 Words
    • 15 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a.x is available to code that is written outside the Sphere class. b.radius is not available to code written outside the Sphere class. c.radius, x, y, and z are called members of the Sphere class. d.z is available to code that is written outside the Sphere class.…

    • 1368 Words
    • 9 Pages
    Satisfactory Essays
  • Powerful Essays

    NOTE: Everything covered in lecture thus far may be on the first exam. The following material from the text may also be on the first exam.…

    • 2246 Words
    • 9 Pages
    Powerful Essays
  • Good Essays

    1. The logical structure in which one instruction occurs after another with no branching is a ______A______.…

    • 765 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Cis 324 Midterm and Answers

    • 2743 Words
    • 11 Pages

    | A name for the function, a name for each parameter, and a name for the return value…

    • 2743 Words
    • 11 Pages
    Good Essays
  • Powerful Essays

    Tic tac toe is a great mental exercise used to improve the thought process in children and adults, tic tac toe is believed to be the oldest game in history but it is still played today including in computer because it was easy to apply in any programming language, this is a game for two players, first you decide who will be using O's and who will using X's. Second decide who will start. The players put their symbol in an empty square when it is his its time. First with three of their symbols along a straight line or diagonally line has won, it was so exciting to play in computer.…

    • 1352 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    Solving C++

    • 345 Words
    • 2 Pages

    For each pair of numbers, when the division algorithm is used to divide a by d, what are the quotient q and remainder r?…

    • 345 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Pointer and Stack

    • 1257 Words
    • 6 Pages

    The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address. The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to.…

    • 1257 Words
    • 6 Pages
    Better Essays
  • Satisfactory Essays

    C C++ User Guide

    • 126111 Words
    • 505 Pages

    Note! Before using this information and the product it supports, be sure to read the information in “Notices” on page 657.…

    • 126111 Words
    • 505 Pages
    Satisfactory Essays
  • Good Essays

    数据结构C语言版 串的块链存储表示和实现.txt成熟不是心变老,而是眼泪在眼里打转却还保持微笑。把一切平凡的事做好既不平凡,把一切简单的事做对既不简单。/* 数据结构C语言版 串的块链存储表示和实现 P78 编译环境:Dev-C++ 4.9.9.2 日期:2011年2月12日 */ #include #include #include #include // LString.h 串的块链存储表示 #define CHUNKSIZE 4 // 可由用户定义的块大小 typedef struct Chunk { char ch[CHUNKSIZE]; //块的数据域 struct Chunk *next; //块的指针域 }Chunk; typedef struct { Chunk *head, // 串的头指针 *tail; // 串的尾指针 int curlen; // 串的当前长度 }LString; char blank = '#'; // 全局变量,用于填补空余 // 初始化(产生空串)字符串T。 void InitString(LString *T) { (*T).curlen=0; (*T).head=…

    • 1320 Words
    • 6 Pages
    Good Essays
  • Better Essays

    death penalty

    • 798 Words
    • 9 Pages

    1. #include #include void main() { int a=5,b=6,c=11; clrscr(); printf("%d %d %d"); getch(); } What will output when you compile and run the above code?…

    • 798 Words
    • 9 Pages
    Better Essays

Related Topics