Learning C Language
C Syntax
C++ Syntax
C is based on library network which means
many fundamental functions for digital processing is already build in. Also, any one
can write a new function and register it to include in the library. All functions
are stored in the header (*.h) file. Here's the example of <stdio.h> included
in a program:
/*This is a printme.cpp
which uses print.*/ function */
#include <stdio.h>
main(void)
{
printf("Hello world!");
return 0;
}
This program displays the "Hello world " message on the command line. The
program needs to be compiled and then execute from the command line of DOS prompt.
The file which is include <stdio.h> does all work for the print function.
Programmmers do not need to be worried about writing the subroutine for the print
function. Its already written and registered in the library of C compiler.
Here's another header file that does math functions:
#include <stdio.h>
#include <math.h>
int main(void)
{
double answer;
answer = sqrt(10.0);
printf("%f", answer);
return 0;
}
In this program <math.h> does the squaring of the value 10.00 as double data type
variable answer.
C++ Syntax:
C++ is a fully developed object oriented programming language though it has evolved from
C. C++ includes all the library and thier functions. In addition, C++ can create
objects as class, inherit its property and methods in another class. There's a lot of
information on the Internet if you are interested. Just type C++ in one of the
search engine's text box and submit it. Here are some syntax samples:
/*This is a hell.cpp file that uses C++ iostream.h header file*/
#include <iostream.h>
void main()
{
cout <<"Hello world";
}
Here's program that creats object as class:
/*This increment.cpp file which has class as public */
#include <iostream.h>
class Increment {
public:
Increment(int c = 0, int i = 1);
void addIncrement() {count += increment; }
void print() const;
private:
int count;
const int increment;
};
Increment::Increment(int c, int i) : increment(i)
{count = c;}
void Increment::print() const
{
cout <<"count = " << count<<", increment =
" << increment << endl;
}
main()
{
Increment value(10, 5);
cout <<"Before increment: ";
value.print();
for(int j=1; j<=3; j++){
void.addIncrement();
cout<<"After increment "<<j
<<": ";
value.print();
}
return 0;
}
Find the information on the
Internet or from a book and figure it out for yourself what does this program do and
understand each syntax and class variables.C++ is a very highly sophiscated object oriented programming
language. Most of the great databases such as Oracle, Cybase, DB, SQL Server are developed
by C++. Operating system like Unix, Windows NT, Windows 98 and Windows 2000 are
developed by C++. It is a language on which all the modern software industries
depend on to develop their product from games to the operating systems.
It is very difficult to master C++. It needs whole life dedicated
on it only if you love to program in C++. If you like it, you will be one of the high
paying professionals on the earth. Excellent C++ programmer can make $1,50,000.00
per year at least in America. If you know this language and you have acedemic
qualification, no matter where you are on earth you will be dragged to the industry. You
will be then the lucy Joe!!
You can also specialize in a particular area of the C++ technology.
The best C++ software are of Borland's C++ Builder and Microsoft's Visual C++. You
can do any thing out of this language from operating systems to the web applications.
As in Visual Basic you can also
develop ADO and RDS components with the C++ language. Unlike Visual Basic C++ is not only
for the windows application development but also for developing applications for any other
operating systems such as Unix, Linux, Macintosh.
