add

Wednesday, 1 February 2017

Basic Input/Output in C++ Programming

C++ Key Words or Reserved Words

Definition:

The words we directly implemented and cannot change during writing a program called key/reserved words of C++
Eg. Double, main, if and else etc.

Explanation:

About reserved words and keywords the some author says both are different but most of author says these are slide difference. I always agree both are same because we can’t change our self if we change these word then this method would be against of C++ programming rule.

The reserved words of C++ may be conveniently placed into several groups. In the first group we put those that were also present in the C programming language and have been carried over into C++. There are 32 of these, and here they are:
auto   const     double  float  int       short   struct   unsigned
break  continue  else    for    long      signed  switch   void
case   default   enum    goto   register  sizeof  typedef  volatile
char   do        extern  if     return    static  union    while
There are another 30 reserved words that were not in C, are therefore new to C++, and here they are:
asm         dynamic_cast  namespace  reinterpret_cast  try
bool        explicit      new        static_cast       typeid
catch       false         operator   template          typename
class       friend        private    this              using
const_cast  inline        public     throw             virtual
delete      mutable       protected  true              wchar_t

The following 11 C++ reserved words are not essential when the standard ASCII character set is being used, but they have been added to provide more readable alternatives for some of the C++ operators, and also to facilitate programming with character sets that lack characters needed by C++.
and      bitand   compl   not_eq   or_eq   xor_eq
and_eq   bitor    not     or       xor
Note that your particular compiler may not be completely up-to-date, which means that some (and possibly many) of the reserved words in the preceding two groups may not yet be implemented.

Variables:

Definition:

Those words or letter we write in our program is known as variables.
Eg. Sum, x, I, salary and num1.

Explanation:

If you starts your variable with number or digit then compiler generate error (1num, 444x,5n)
But you should always start your variable with alphabets. Always use variable creative if you use “n1”,

In small Program you understand the “n1” but in large Program you are unable to understand or other Programmer can’t understand your program properly.Data Types:

Those types of Data programmers wants to store in memory is known as data types.
Eg. Int, float, double, short and long etc.

Data types and memory:

Complete data types we written as: int  sum. The reason of the highlighted data is this sum is variable and which is reference of memory and lies of data which gives reference sum in memory is integer. For example int sum=10. Then the 10 is reference as in computer memory.
Memory












10













Sum

Basic input and output of C++:

Definition:

During running the program if user gives some information to computer called input and it’s vice versa is known as output.

Explanation:

Cout is key word and we use for giving output for user. Cin is also keyword we use for taking input from user.  We should always use << sign for output and >> sign for input.

Some important basics for writing program:

\t  =>   to giving space between text                             \b=>     to giving backspace between text
\n=>     to start text for new line                                   endl =>    to end line
Eg. For Basic input and output of C++

 watch My Complete Video Lecture About first post & this topic:


#include<iostream>
Using namespace std;
Int main ( )
{
Int sum;
Int num1, num2;
Cout << ”\t   please enter the first Number  ” <<  endl ;                                    //for out put
 Cin>>num1;                                                                                                           //for input
Cout << ”\t    please enter the first Number  “ <<   endl ;                               //for out put
Cin>>num2;                                                                                                             //for input
Sum = num1 + num2;                                                                                                     
Cout << ”\t    The sum of given Numbers is:    ” << sum<<  endl ;                  //for out put
Cout<<”\n\n\n\n\n”;
System (“Pause”);
}


0 comments:

Post a Comment