Tuesday, February 16, 2010

Learning C/C++ Introduction Contd.. Class 2 Dated 4th Feburary 2010

Assembler (Wiki Assembler): is a small program that converts assembly language to machine language.

Translator (Wiki Translator ): converts any source code to designation or machine level language.

Compiler (Wiki Compiler):
  • It compiles and checks the whole program for any error
  • Execution is fast as compare to interpreter
  • Debugging is slower as compare to interpreter
Interpreter (Wiki Interpreter):
  • It checks the program line by line and converts to machine level language if no error found
  • Execution is slow
  • Debugging is faster
Variables (Wiki Variables): It is a name/space occupies the memory where a data is to be stored and retrieved i.e. int a=5;

Constant (Wiki Constant): It is a fixed value i.e. 0-9
  • Integer constant : 0-9
  • Float constant: with decimals
  • Character constant: a, b, c
  • String constant: "Name" with multiple characters
Rules of C programing (Wiki C_syntex):

  • It's written in lower care
  • Each statement ends with semicolon (;)
  • Each statement is written in the main under compound curly brackets i.e. main {program}
Rules of naming Variables (Wiki Variables):
  • It must start with alphabet i.e. a, b, c
  • Special symbols are not allowed
  • No blank space is allowed in between
  • Only underscore (_) is allowed
  • Numerical are not allowed
Header file (Wiki Header File):

#include < stdio.h >
(stdio= Standard input output)
#include < conio.h >
(Conio= Console input output) used for displaying

printf ("Enter the first number");
scanf ("%d", & a);
printf ("%d", a)

Data Types (Wiki Data_Types): types of data used in programming

Name Sign Size
char %c 1 Byte
int %d 2 Byte
float %f 4 Byte
long int %ld 4 Byte
double fload %lf 8 Byte

Simple C program - Addition

/*-----------------------------start of program-------------------------


void main()
int a, b, c;
printf ("Enter the first number = ");
scanf ("%d", & a);

printf ("Enter the second number = ");
scanf ("%d", & b);


printf ("Addition = %d", c);

----------------------------------end of the program--------------------*/
Now in compiler

Compile = Alt+F9
Run = Ctrl+F9
Output = Alt + F5

Comments: It is a statement which can we written anywhere in the program to understand the logical function for future use. Syntax for comment is /* Comment */ anythign in between /* and */ wont be analyzed by compiler.

Learning C/C++ Introduction Class 1 Dated 3rd Feburary 2010

I was craving for learning C/C++ since long. I did try to learn it myself through various tutorials and few book, but unfortunately could not learn more and there were breaks in it. So I joined one institute. I am writing this for my reference and for those who intend to learn it. I am from non computing background and in research, I am learning it as I have interest in it. I would try to make it as easy as possible. I am sure there would be many flaws, try filling it from other resources too. I am also linking topics to the places on the web I think good for further references. You can also find copy pasted text from various places, just to make work easy for me and help me to organize it properly. Before you start you would need following:
  • A computer (anyone would do I guess, C/C++ doesn't need much)
  • A IDE there are various available, use Turbo C that is freely available, though it doesn't work well with Vista and Windows 7, if you are on any other OS it would just be fine, in Linux based system GCC would just be fine.
  • If you are on Vista or Windows 7 try this an older version of Turbo C, I could not find a place to upload a file, mail me if you need it at drsanjivk@gmail.com

Introduction (Wiki C (Programing Language)):

It is needed for starters, I know its all blah blah, but for some it is helpful and would be of interest in long run. Here we go.

Language: It is a medium of communication. (Various available, C, C++, VB, JAVA)

Generation of languages (Wiki Programming_language_generations):

1. Machine Level Language (Wiki First generation language):
All the instructions are given in 0 and 1 form (i.e. binary)
Advantages - no need of compilers and faster execution
Disadvantages - Difficult to understand
Learn Binary conversion i.e. digits to binary

2. Assembly Language (Wiki Assembly_Language):
All instructions are written in some mnemonic code i.e. + --> add
Advantage - language is machine dependent and faster to execute but less then machine language
Disadvantage- Not very easy to understand

3. Mid Level Language (Wiki C++):
C is supported by both machine language and high level language. C was developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system, California.
  • It has powerful patter
  • Its a procedural language
  • Supports both low and high level language
  • Command line argument based
  • Machine independent
4. High level language (Wiki High-level):
Advantage is that it is simple languages and is written in simple English. It is easy to understand, write and work with, i.e. C++, JAVA, VB, .net etc.

5.Fourth level language (Wiki Fourth-generation_programming_language):
Advantage is that multiple lines can be written in single command line i.e. select x from student where name = x i.e. mySQL, ORACLE, SQLplus. SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. This version, initially called SEQUEL, was designed to manipulate and retrieve data stored in IBM's original relational database product, System R.