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
  • Powerful Essays

    If > denotes +, < denotes –, + denotes  , Λ denotes x, – denotes =, x denotes > and =…

    • 1942 Words
    • 8 Pages
    Powerful Essays
  • Powerful Essays

    ● Converts the value of i to double and stores it in d. This conversion is done automatically by the compiler, because double data type is normally wider than int, there is absolutely no risk storing int in double.…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful 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
  • 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
  • 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

    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
  • 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