You can abbreviate a text by putting it inside opening <abbr> and closing </abbr> tags.
If present, the title attribute must contain this full description and nothing else.

[code type="HTML"]
<!DOCTYPE html>
<html>
<head>
<title>Text Abbreviation</title>
</head>
<body>
<p>My best friend's name is <abbr title="Abhishek">Abhy</abbr>.</p>
</body>
</html>
[/code]

This will produce the following result: 


My best friend's name is Abhy.

Anything that appears within <strong>...</strong> element is displayed as important text.

[code type="HTML Code"]
<!DOCTYPE html>
<html>
<head>
<title>Strong Text Example</title>
</head>
<body>
<p>The following word uses a <strong>strong</strong> typeface.</p>
</body>
</html>
[/code]

This will produce the following result:


The following word uses a strong typeface.



Anything that appears with-in <mark>...</mark> element, is displayed as marked with
yellow ink.

[code type="HTML Code"]
<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>
</head>
<body>
<p>The following word has been <mark>marked</mark> with Blue</p>
</body>
</html>
[/code]

This will produce the following result:

[code type="Resul Page"]
The following word has been marked with Blue.
[/code]





In algebra, variables are used to represent numbers. The same is true in C++, except C++ variables also can represent values other than numbers. variable.cpp uses a variable to store an integer value and then prints the value of the variable.

[code type="Variable.cpp"]#include <iostream>
using namespace std;
int main() {
int x;
x = 10;
cout << x << endl;
}
[/code]

  • int x;
This is a declaration statement. All variables in a C++ program must be declared. A declaration specifies the type of a variable. The word int indicates that the variable is an integer. The name of the integer variable is x. We say that variable x has type int. C++ supports types other than integers, and some types require more or less space in the computer’s memory. The compiler uses the declaration to reserve the proper amount of memory to store the variable’s value. The declaration enables the compiler to verify the programmer is using the variable properly within the program; for example, we will see that integers can be added together just like in mathematics. For some other data types, however, addition is not possible and so is not allowed. The compiler can ensure that a variable involved in an addition operation is compatible with addition. It can report an error if it is not. The compiler will issue an error if a programmer attempts to use an undeclared variable. The compiler cannot deduce the storage requirements and cannot verify the variable’s proper usage if it not declared. Once declared, a particular variable cannot be redeclared in the same context. A variable
may not change its type during its lifetime.
  • x = 10;
This is an assignment statement. An assignment statement associates a value with a variable. The key to an assignment statement is the symbol = which is known as the assignment operator. Here the value 10 is being assigned to the variable x. This means the value 10 will be stored in the memory
location the compiler has reserved for the variable named x. We need not be concerned about where
the variable is stored in memory; the compiler takes care of that detail. After we declare a variable we may assign and reassign it as often as necessary. 
  • cout << x << endl;
This statement prints the variable x’s current value.

The meaning of the assignment operator (=) is different from equality in mathematics. In mathematics, = asserts that the expression on its left is equal to the expression on its right. In C++, = makes the variable on its left take on the value of the expression on its right. It is best to read x = 5 as “x is assigned the value 5,” or “x gets the value 5.” This distinction is important since in mathematics equality is symmetric: if x = 5, we know 5 = x. In C++, this symmetry does not exist; the statement

5 = x;

attempts to reassign the value of the literal integer value 5, but this cannot be done, because 5 is always 5 and cannot be changed. Such a statement will produce a compiler error.


C++ supports a number of numeric and non-numeric values. In particular, C++ programs can use integer values. It is easy to write a C++ program that prints the number four, as example 1


[code type="Example 1"]#include <iostream>
 using namespace std;
 int main()
{ cout << 4 << endl; }
[/code]

[code type="Example2"]#include <iostream>
 using namespace std;
int main()
{ cout << "4" << endl; }
[/code]

Both programs behave identically, but example 1 prints the value of the number four, while Listing 3.2 (number4-alt.cpp) prints a message containing the digit four. The distinction here seems unimportant, but the presence or absence of the quotes can make a big difference in the output. In C++ source code, integers may not contain commas. This means we must write the number two thousand, four hundred sixty-eight as 2468, not 2,468. In mathematics, integers are unbounded; said another way, the set of mathematical integers is infinite. In C++ the range of integers is limited because all computers have a finite amount of memory. The exact range of integers supported depends on the computer system and particular C++ compiler. C++ on most 32-bit computer systems can represent integers in the range −2,147,483,648 to +2,147,483,647.

What happens if you exceed the range of C++ integers?

[code type="Exeed cpp"]#include <iostream>
using namespace std;
int main()
{ cout << -3000000000 << endl; }
[/code]

Negative three billion is too large for 32-bit integers, however, and the program’s output is obviously wrong:

[code type="Result"]1294967296[/code]

The number printed was not even negative! Most C++ compilers will issue a warning about this statement. secrefsec:expressionsarithmetic.errors explores errors vs. warnings in more detail. If the compiler finds an error in the source, it will not generate the executable code. A warning indicates a potential problem and does not stop the compiler from producing an executable program. Here we see that the programmer should heed this warning because the program’s execution produces meaningless output. This limited range of values is common among programming languages since each number is stored in a fixed amount of memory. Larger numbers require more storage in memory. In order to model the infinite set of mathematical integers an infinite amount of memory would be needed!

[code type="CPP Code"]#include <iostream> using namespace std; int main() { cout << "This is a simple C++ program!" << endl; } [/code]

You can type the text into an editor and save it to a file named simple.cpp. The actual name of the file is irrelevant, but the name “simple” accurately describes the nature of this program. The extension .cpp is a common extension used for C++ source code. After creating this file with a text editor and compiling it, you can run the program. The program prints the message.



[code type="CPP Result"]This is a simple C++ program![/code]

TECH SHARPENER

.
Powered by Blogger.