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-------------------------


#include
#include

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

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

c=a+b;

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

----------------------------------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.

No comments: