Unit 1 An Overview of C Language -Tin học đại cương (IT1110)

Unit 1 An Overview of C Language

lOMoARcPSD| 27879799
Downloaded by VietJack TV Official (vietjackvideos@gmail.com)
lOMoARcPSD| 27879799
Downloaded by VietJack TV Official (vietjackvideos@gmail.com)
lOMoARcPSD| 27879799
3
Downloaded by VietJack TV Official (vietjackvideos@gmail.com)
lOMoARcPSD| 27879799
4
Derived from the B language
lOMoARcPSD| 27879799
5
Labs in the 1980s.
Overcame several shortcomings of C
lOMoARcPSD| 27879799
6
lOMoARcPSD| 27879799
7
C++ adds more libraries with funcons for object
lOMoARcPSD| 27879799
8
lOMoARcPSD| 27879799
9
lOMoARcPSD| 27879799
10
The Search Menu
lOMoARcPSD| 27879799
11
lOMoARcPSD| 27879799
12
lOMoARcPSD| 27879799
13
And ends this way
lOMoARcPSD| 27879799
14
A Sample C Program
1. #include <stdio.h>
2. #include <limits.h>
3. main ()
4. {
5. prin("Size of Char Max %d\n", CHAR_MAX);
6. prin("Size of Char Min %d\n", CHAR_MIN);
7. prin("Size of int min %d\n", INT_MIN);
8. prin("Size of int max %d\n", INT_MAX);
9. prin("Size of long min %ld\n", LONG_MIN);
10. prin("Size of long max %ld\n", LONG_MAX);11. prin("Size of short
min %d\n", SHRT_MIN);
12. prin("Size of short max %d\n", SHRT_MAX);
13. prin("Size of unsigned char %u\n", UCHAR_MAX);
14. prin("Size of unsigned long %lu\n", ULONG_MAX);
15. prin("Size of unsigned int %u\n", UINT_MAX);
16. prin("Size of unsigned short %u\n", USHRT_MAX);
lOMoARcPSD| 27879799
15
17.}
lOMoARcPSD| 27879799
16
lOMoARcPSD| 27879799
17
C Program Structure
lOMoARcPSD| 27879799
18
#include
lOMoARcPSD| 27879799
Variable Declaraons
Example declaraons:
lOMoARcPSD| 27879799
20
Data Types
Integer variables: int a, b ;
Integer variables, like a or b, store only whole
numbers like 3 or 7, not 3.33 or 7.65, and only up
to certain maximum values.
Floang point variables: oat c, d ;
Floang point variables, like c or d, store raonal
numbers, like 3.14159, but only a limited number
of digits of precision.
| 1/34

Preview text:

lOMoAR cPSD| 27879799
Downloaded by VietJack TV Official (vietjackvideos@gmail.com) lOMoAR cPSD| 27879799
Downloaded by VietJack TV Official (vietjackvideos@gmail.com) lOMoAR cPSD| 27879799 3
Downloaded by VietJack TV Official (vietjackvideos@gmail.com) lOMoAR cPSD| 27879799 Derived from the B language 4 lOMoAR cPSD| 27879799 Labs in the 1980s.
Overcame several shortcomings of C 5 lOMoAR cPSD| 27879799 Weak typing 6 lOMoAR cPSD| 27879799
C++ adds more libraries with functions for object 7 lOMoAR cPSD| 27879799 8 lOMoAR cPSD| 27879799 9 lOMoAR cPSD| 27879799 The Search Menu 10 lOMoAR cPSD| 27879799 11 lOMoAR cPSD| 27879799 12 lOMoAR cPSD| 27879799 And ends this way 13 lOMoAR cPSD| 27879799 A Sample C Program 1. #include 2. #include 3. main () 4. { 5.
printf("Size of Char Max %d\n", CHAR_MAX); 6.
printf("Size of Char Min %d\n", CHAR_MIN); 7.
printf("Size of int min %d\n", INT_MIN); 8.
printf("Size of int max %d\n", INT_MAX); 9.
printf("Size of long min %ld\n", LONG_MIN); 10.
printf("Size of long max %ld\n", LONG_MAX);11. printf("Size of short min %d\n", SHRT_MIN); 12.
printf("Size of short max %d\n", SHRT_MAX); 13.
printf("Size of unsigned char %u\n", UCHAR_MAX); 14.
printf("Size of unsigned long %lu\n", ULONG_MAX); 15.
printf("Size of unsigned int %u\n", UINT_MAX); 16.
printf("Size of unsigned short %u\n", USHRT_MAX); 14 lOMoAR cPSD| 27879799 17.} 15 lOMoAR cPSD| 27879799 16 lOMoAR cPSD| 27879799 C Program Structure 17 lOMoAR cPSD| 27879799 #include 18 lOMoAR cPSD| 27879799 Variable Declarations Example declarations: lOMoAR cPSD| 27879799 Data Types Integer variables: int a, b ;
Integer variables, like a or b, store only whole
numbers like 3 or 7, not 3.33 or 7.65, and only up to certain maximum values. Floating point variables: float c, d ;
Floating point variables, like c or d, store rational
numbers, like 3.14159, but only a limited number of digits of precision. 20