#include <stdio.h> #include <limits.h> int main() { printf("int 存储大小 : %lu \n", sizeof(int)); return 0; }
#include <stdio.h> #include < a float .h> int main () { the printf ( " a float store a maximum number of bytes:% D \ n- " , the sizeof ( a float )); the printf ( " a float minimum:% E \ n- " , FLT_MIN); the printf ( " a float maximum:% E \ n- " , FLT_MAX); the printf ( " precision value:% D \ n- " , FLT_DIG); return 0 ; }
int i, j, k; char c, ch; float f, salary; double d;
int i, j, k; char c, ch; float f, salary; double d;
extern int i; // declaration, not a definition int i; // declaration, also the definition of
#include <stdio.h> // function defined outside variables x and y int x; int y; int addtwonum () { // the function declaration variables x and y for the external variable extern int x; extern int y; // to external variable (global variable) x and y assignment X = . 1 ; y = 2 ; return X + y; } int main () { int Result; // function addtwonum call Result = addtwonum (); the printf ( " Result is:% d " ,result); return 0; }
#include <stdio.h> / * the external variable declarations * / extern int X; extern int Y; int addtwonum () { return X + Y; }
#include <stdio.h> / * define two global variables * / int X = . 1 ; int Y = 2 ; int addtwonum (); int main ( void ) { int Result; Result = addtwonum (); the printf ( " Result It was:% D \ n- " , Result); return 0 ; }
#include <stdio.h> #define LENGTH 10 #define WIDTH 5 #define NEWLINE '\n' int main() { int area; area = LENGTH * WIDTH; printf("value of area : %d", area); printf("%c", NEWLINE); return 0; }
const type variable = value;
#include <stdio.h> int main() { const int LENGTH = 10; const int WIDTH = 5; const char NEWLINE = '\n'; int area; area = LENGTH * WIDTH; printf("value of area : %d", area); printf("%c", NEWLINE); return 0; }