Professional Documents
Culture Documents
Pe PRF
Pe PRF
This statement suggests that var1 is a variable of storage class auto and type
int.
Variables declared within function bodies are automatic by default. They are
recreated each time a function is executed.
Since automatic variables are local to a function, they are also called local
variables. To learn more visit C storage class.
The continue statement skips the statements after it inside the loop for the
iteration.
for (i=1;i<=10;++i){
if (i==3)
continue;
if (i==7)
break;
printf("%d ",i);
Output
1 2 4 5 6
When i is equal to 3, the continue statement comes into effect and skips 3.
When i is equal to 7, the break statement comes into effect and terminates
the for loop. To learn more, visit C break and continue statement
switch(expression)
case '1':
break;
case '5':
break;
default:
//some statements to execute when default;
char
The char keyword declares a character variable. For example:
char alphabet;
const
An identifier can be declared constant by using the const keyword.
const int a = 5;
do
printf("%d ",i);
i++;
while (i<10)
float number;
double longNumber;
if (i == 1)
printf("i is 1.")
else
i is not 1
enum
Enumeration types are declared in C programming using keyword enum. For
example:
enum suit
hearts;
spades;
clubs;
diamonds;
};
extern
The extern keyword declares that a variable or a function has external linkage
outside of the file it is declared.
for
There are three types of loops in C programming. The for loop is written in C
programming using the keyword for . For example:
printf("%d ",i);
Output
0 1 2 3 4 5 6 7 8
To learn more, visit C for loop.
goto
The goto statement is used to transfer control of the program to the specified
label. For example:
if (i==10)
goto error;
error:
Output
int
The int keyword is used to declare integer type variables. For example:
int count;
return
The return keyword terminates the function and returns the value.
int func() {
int b = 5;
return b;
This function func() returns 5 to the calling function. To learn more, visit C
user-defined functions.
sizeof
The sizeof keyword evaluates the size of data (a variable or a constant).
#include <stdio.h>
int main()
printf("%u bytes.",sizeof(char));
1 bytes.
register
The register keyword creates register variables which are much faster than
normal variables.
static
The static keyword creates a static variable. The value of the static variables
persists until the end of the program. For example:
struct
The struct keyword is used for declaring a structure. A structure can hold
variables of different types under a single name.
struct student{
char name[80];
float marks;
int age;
}s1, s2;
typedef
The typedef keyword is used to explicitly associate a type with an identifier.
kg bear, tiger;
union
A union is used for grouping different types of variables under a single name.
union student {
char name[80];
float marks;
int age;
void testFunction(int a) {
.....
Here, the testFunction() function cannot return a value because its return type
is void.
volatile
The volatile keyword is used for creating volatile objects. A volatile object can
be modified in an unspecified way by the hardware.
char 1 %c
Type Size (bytes) Format Specifier
float 4 %f
double 8 %lf
signed char 1 %c
unsigned char 1 %c
%d for int
%f for float
%c for char
để hiện số thập phân trong C chúng ta sẽ sử dụng chuỗi định dạng %f trong
hàm printf. Vậy bây h ta thay đổi chuỗi định dạng thành %.xf với x là số chữ
số thập phân muốn hiện sau dấu phẩy. Như vậy tất cả các số sau x chữ số sẽ bị
loại bỏ khi hiển thị.
ASCII Value
#include <stdio.h>
int main()
char chr;
scanf("%c", &chr);
return 0;