O GoConqr está de visual novo! Conte para nós o que você achou.

Notas

C- Get Started

Dakshali Merya C Programming CDAC Inglês 1 página

Conteúdo das notas (1)

Página 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);

}

Informações

Descrição
CDAC C Programming Notas sobre C- Get Started, criado por Dakshali Merya em 30-05-2024.
Criado por
Dakshali Merya · mai 2024
Atualizado
19 jun 2024
Visualizações
2
Avaliação

Mais sobre C Programming Basics

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?