comment 0

Basic of C/C++ – Day 1


  • The C/C++ executable contains machine code which will be execute directly by the processor
  • Usually every C/C++ program starts with the method void main()
  • A program, whatever its size, consist of functions and variables. A function contains statements that specify the computing operations to be done, and variables store values used during the computation.

Compile and Linking Process

To produce an executable program from the source code requires a 3-stage process :

  • Pre-process: First the C pre-processor is run on each source file. This interprets pre-processor directives, which  are indicated by the # symbol. The output of the preprocessor will be files containing C/C++ code.
  • Compile: The expanded source code file resulting from pre-processing is compiled to produce an object file containing the raw machine instructions.
  • Linking: The Linker combines one or more object files together with standard libraries (which contain collections of object files). This is the program that one actually runs.

Just Hello World :D

//include information about standard library
#include <stdio.h>
/*define a function called main that received no argument avalues. 
statements of main are enclosed in braces to print this sequence of Characters n represents the newline character.*/
void main()
	printf(“hello, worldn”);

More than Hello World :P

#include <stdio.h>
void main()
/*in C, all variables must be declared before they used,
usually at the begining of the function before any executable statements.
A declaration announces the properties of variables; it consists of a name and a list of variables*/
	int celcius, fahr;
	int lower, upper, step;
	lower = 0;
	upper = 300;
	step = 20;
	fahr = lower;
		while (fahr <= upper) {
		celcius = 5 * (fahr-32) / 9;
		printf(%dt%dn”, fahr, celcius);
		fahr = fahr + step;

Filed under: C++

Leave a Reply

Your email address will not be published. Required fields are marked *