Notizen
C- Get Started
Inhalt der Notizen (1)
Seite 1
IDE - Integrated Development Environment : Used : Edit and Compile Code.
C QuickStart: to save file filename.c (eg.myfirstprogram.c)
#include ............. 1
..............2
int main() { ..............3
printf("Hello World!"); .............4
return 0; ..............5
}
C Syntax :
Line1 : Header file library ( works with input outout func)
such as printf
Line2 : blank line. "C ignores white space"
Line3 : main() is called function.
Line4 : printf
" Every C statment ends with ; "
C Statments :
Instructions are called statments.
(" " : double quotes is must wrapped around a text)
\n : creates inserts text to new line
\t : creates text in a horizontal line
\\ : backslash character (\)
\" : Insert a double quote charater.
// : Single Line
/* starts ends */ : Multi-line
C Variables
int, float, char
--> Declaring variables :
int myNum = 16
// Declare a variable
int myNum;
myNum = 12;
--> Format Specifiers : used together with printf(), which tells compiler what type of data the variable is storing.
it starts with % sign followed by a character
--> int : %d, char : %c, float : %f, double : %lf, strings : %s
C Variable Names : Identified with unique names
( unique names are called identifiers)
C Data Types :
Data type Size
int 2 or 4 bytees
float 4 bytes
double 8 bytes
char 1 bytes
C Type Conversion :
Two types : Implicit Conversion (automatically), Explicit (Manually).
C Boolean Variables :
data type that can only have one or two value
bool values are retuned as integers
>> 1 (or any other number that is not 0) = TRUE
>> 0 = FALSE
C If...Else :
THE IF STAT : if (condition) {
// block of code
}
THE ELSE STAT : if (condition) {
//block of code
} else {
//block of code
}
THE ELSE IF STAT :
if (condition1) {
//block of code
} else if (condition2) {
//block of code
} else {
}
C SWITCH STAT :
switch (expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
C WHILE LOOP : Syntax
while (condition) {
// code block to be executed
}
C Do/while Loop : Syntax
do {
// code block to be executed
}
while (condition);
C FOR LOOP : Syntax
for (expression 1; expression 2; expression 3) {
// code block to be executed
}
Expression 1 is executed (one time) before the execution of the code block.
Expression 2 defines the condition for executing the code block.
Expression 3 is executed (every time) after the code block has been executed.
For example :
int i;
for (i = 0; i < 5; i++) {
printf("%d\n", i);
}
Informationen
- Beschreibung
- CDAC C Programming Notiz am C- Get Started, erstellt von Dakshali Merya am 30/05/2024.
- Erstellt von
- Dakshali Merya · Mai 2024
- Aktualisiert
- 19 Jun 2024
- Aufrufe
- 2
- Bewertung