Saturday, July 9, 2011

C++ : Things you might know or :?

Some of us have already studied C++ language but being in a computer stream demands from you to stand out from those who know only the text or the ordinary used commands or basic knowledge.

Here are some.... which some/all of you might know... but a quick revision or something new for you...


1. REFERNCE

An alternate name for an object in C++. It provides an alias name for previously defined variables(s).

SYNTAX:            type &ref-name=var-name;

EXAMPLE:        int total;
                              int &sum=total;
                              total=100;
                              cout<<sum<<"  "<<total;
OUTPUT:          100  100



2. SETPRECISION MANIPULATOR using IOS flag

It is used to set number of decimal places using ios flag.

EXAMPLE:         cout.setf(ios::fixed);
                               cout<<setprecision(5)<<12.345678;

OUTPUT:            12.34567           (No Rounding Off)

                          
Additional ios flags:

left                : displays left justified output
right             : displays right justified output
showpoint : displays decimal and trailing zeros even if decimal places are not needed
uppercase : displays the "e" in E-notation as "E"
showpos    : displays a leading plus(+) before the value
scientific   : displays floating point numbers in scientific ("E") notation
fixed           : displays floating point numbers in normal notation ,i.e, no trailing zeros and no scientific
                        notaions.

3. SIZEOF Operator

 Sizeof is a unary compile-time operator that returns length (in bytes) of the variable or parenthesized type-specifier that it precedes.
It can be used as:
                  sizeof var; (where var is a declared datatype)
                  sizeof (type) (where type is a C++ data type)

4. COMMA Operator

Comma operator is used to string together several expressions. The group of expressions separated by comma (,) is evaluated left-to-right in sequence and the result of rightmost expression becomes the value of the total comma-separated expression.

EXAMPLE: b=(a=3,a+1);

first assigns a the value 3 and then assigns b the value a+1 i.e., 4. The parenthesis are necessary because the comma operator has lower precedence than the assignment operator. 






If you like it or otherwise, then please comment below....!!!

Saturday, February 5, 2011

How to run C++ on windows 7 (64 bit)

"This is an adapted version of some orignal work...
Duplicated for fun and PrAcTiCe... :P" (see original)

Some chaos in your mind to run C++ on your 64 bit machine?
Or you are just switching your mind to run it on your PC or install XP and so on???

There is a solution..
A step-by-step solution how to install Turbo C++ on 64 bit Windows 7:

1. Install a software DosBox ver 0.74: download here
2. Create a folder, for example C++ (c:\C++\).
3. Download and extract Turbo C++ to the C++ folder (c:\C++\): download here
4. Run DosBox 0.74


5. Type the following commands in the command prompt screen of DosBox:

    mount d c:\C++



A message like "Drive D is mounted as a local directory c:\C++\" would appear on the screen.
(This step creates a virtual drive D on which files of folder C++ are mounted and you use C++ through DosBox)

6. Type d: This will shift to the above virtual drive d: created.




7.Now write the following commands:

    cd tc
    cd bin




then type tc  or tc.exe (which will start the C++ IDE interface).




8. In the Turbo C++ goto:
   Options>Directories> Change the source of TC to the source directory [D] ( i.e. virtual D: refers to original      c:\Turbo\ . So change the path  to something like D:\TC\include and D:\TC\lib respectively )



This process has to be repeated every time you have to start C++.

To overcome this  monotony just follow the following steps:



To Start TurboC++ directly in DosBox automaticaly:


Go to start and open DosBox 0.74 > Options > DosBox 0.74 Options



Go to the end of the page and type:


mount d c:\C++
d:
cd tc
cd bin
tc




Note:
1. To have full screen view: Press alt+enter.
2. Do not press ctrl+F9. It is a DosBox command and will close it.
So compile and run the program using the mouse only..