Internship notes
Internship notes
GCC: GCC stands for "GNU compiler collection" it is a collection of libreary's and
header files which is used to compile a C program.
1.Source code: In c language file saved with [.c] format is called source code.
2.Expandable file[.i]:
every [.c] file converted into [.i] called Expandable file.
-During creation of [.i] file compiler replace the code of the header file with
there actual code.
-to convert source file to Expandable file We need to use this command gcc -E
file _name.c -o file_name.i
4.Object file[.o]:
Assembler file is converted into object files.
-one or more than one file can be created by one Assembler file.
-linker is use to integrate all object file and create and executable file.
-to convert [.s] file to [.o] file we can use following command:
gcc -c file_name -o file-name.o
TCC:
VARIABLES:
Syntax:
variable_name=value;
eg:-
x=23;
ch='A';
Syntax:
data_type variable_name;
eg:-
int x;
bool y;
float cgpa;
Syntax:
data_type variable_name=value;
eg:-
int num=12;
int float=34.4;
Scope:
variable is define inside curly brackets{ }. and it is called the scope of
variable.
-variable is destroy outside the scope.
Global Variable:
The variable which have scope entire the program.
Local Variable:
variable which scope is fixed inside program.
int_1; valid
int_1_1; valid
int x y; invalid
Input/output:
printf():
printf() function is use to print some output into consol window.
scanf():
-Am-percent sign '&' is use to get the addres of particular memory location.
-scanf() takes formated input from the user.
-you can take more then one input at a time using scanf() function.
Seperaters:
usually next line or blank space is use as seperater otherwiswe we can
use any special character or seperater inside scanf().
STORAGE CLASS:
In C language we can store data inside different hierarchy of
computer memory.
1. auto:
Syantax:
auto variable_name; //definition
auto variable_name=value //definition and initilization
2.extern:
extern keyword says compiler to the variable is define somewere else in the
program or another file.
Syntax:
extern variable_name;
3.Static:
static keyword tells compiler to store variable inside stack.
-static keyword always decleared once in a program.
Syntax:
satatic data_type variable_name;
4.register:
register keyword says compiler to allocate memory in register for
particular variable.
-It was not possible to store data in register everytime.
Syntax:
register data_type variable_name=value;
Format Specifier:
It is use to define format of data type:
%d : int
%u : unsigned int
%f : float
%c : char
%s : string
%o : octal value
%p : address in hexadecimal
%lf : double
%lu : unsigned long
%llu : unsigned long long
DATA TYPES:
Data Types refers to types of data in computer science.
eg:-
short (size of short is 2 byte)
int (size of int is 2^32)
unsigned int
long
long long
float (size of float is 4 byte)
double (size of double is 8 byte)
2. Non-Primitive:
Its depend on primitive data type.
String,Array,Pointer
OPERATORS:
Operators are the operations performs between one or more then one
operands.
1. Unary Operator:
These are the operators use with only one operand.
eg:
+,-,++,--,!,~,sizeof()
Incrementor operator:
Incrementor operator is use to increase value by one.
(i). pre-incrementor:
It increase value first then assign.
eg:
++x,++y,++z;
(ii). post-incrementor:
It assign value first then increase the value of
var.
eg:
x++,y++,z++;
Decrement Operator:
Decrement Operator reduce the value of variable by one.
-decrement operator only valid for variables not for
constant.
-decrement operator are of two types:-
2. Binary Operator:
This are the operators used with two operands.
eg:
+,-,*,/,%,&(AND),|(OR),^(XOR),<<(Left shift),>>(Right
shift)
-Bitwise AND(&):
It return 1 when both bits are 1.
b1 | b2 | b1&b2
-----------------------------|------------|--------------------
0 | 0 | 0
1 | 0 | 0
0 | 1 | 0
1 | 1 | 1
| |
-Bitwise OR(|):
It return 1 when at least one bit is on.
b1 | b2 | b1&b2
------------------------------|----------|------------------------
0 | 0 | 0
1 | 0 | 1
0 | 1 | 1
1 | 1 | 1
| |
Q.) 10 << 2
1 0 1 0
1 0 1 0 0
1 0 1 0 0 0
-Logical OR( || ):
It return true when atleast one comndition is true.
Syntax:-
condition1 || condition2;
-Comparision Operator:
-Assignment operator:
= (equal to)
+= (plus equal to)
-= (minus equal to)
/= (divide equal to)
*= (multiply equal to)
3. Ternary Operator:
Ternary operator is operate with three operand.
Operators Priority
Associtivity
!,~,++,-- 1 right to
left
*,/,% 2 left to
right
+,- 3 left to
right
<<,>> 4 left to
right
Conditional Statement's:
In C\C++ conditional statements is use to execute code with some
condition.
Syntax:
if( condition-1 ){