C语言
-
在C中从函数返回数组-C语言实例教程|
在C中从函数返回数组 #include stdio.h /* function to generate and return random numbers */ int * getRandom ( ) { static int r [ 10 ]; int i ; /* set the seed */ srand ( ( un...
-
访问二维数组元素-C语言实例教程|
访问二维数组元素 #include stdio.h int main () { /* an array with 5 rows and 2 columns*/ int a [ 5 ][ 2 ] = { { 0 , 0 }, { 1 , 2 }, { 2 , 4 }, { 3 , 6 },{ 4 , 8 }}; int i , j...
-
访问数组元素-C语言实例教程|
访问数组元素 #include stdio.h int main () { int n [ 10 ]; /* n is an array of 10 integers */ int i , j ; /* initialize elements of array n to 0 */ for ( i = 0 ; i 10 ; i ++ ) ...
-
形式参数-C语言实例教程|
形式参数 #include stdio.h /* global variable declaration */ int a = 20 ; int main () { /* local variable declaration in main function */ int a = 10 ; int b = 20 ; int c = 0 ; pr...
-
局部和全局变量-C语言实例教程|
局部和全局变量 #include stdio.h /* global variable declaration */ int g = 20 ; int main () { /* local variable declaration */ int g = 10 ; printf ( value of g = %d , g ); ret...
-
全局变量-C语言实例教程|
全局变量 #include stdio.h /* global variable declaration */ int g ; int main () { /* local variable declaration */ int a , b ; /* actual initialization */ a = 10 ; b = 20 ; g = ...
-
局部变量-C语言实例教程|
局部变量 #include stdio.h int main () { /* local variable declaration */ int a , b ; int c ; /* actual initialization */ a = 10 ; b = 20 ; c = a + b ; printf ( value of a = %d, ...
-
函数调用-C语言实例教程|
函数调用 #include stdio.h /* function declaration */ int max ( int num1 , int num2 ); int main () { /* local variable definition */ int a = 100 ; int b = 200 ; int ret ; /* call...
-
C中的goto语句-C语言实例教程|
C中的goto语句 #include stdio.h int main () { /* local variable definition */ int a = 10 ; /* do loop execution */ LOOP : do { if ( a == 15 ) { /* skip the iteration */ a = a + 1...
-
C中的continue语句-C语言实例教程|
C中的continue语句 #include stdio.h int main () { /* local variable definition */ int a = 10 ; /* do loop execution */ do { if ( a == 15 ) { /* skip the iteration */ a = a + 1 ; ...
-
C中的break语句-C语言实例教程|
C中的break语句 #include stdio.h int main () { /* local variable definition */ int a = 10 ; /* while loop execution */ while ( a 20 ) { printf ( value of a: %d , a ); a ++ ; if (...
-
C中的嵌套循环-C语言实例教程|
C中的嵌套循环 #include stdio.h int main () { /* local variable definition */ int i , j ; for ( i = 2 ; i 100 ; i ++ ) { for ( j = 2 ; j = ( i / j ); j ++ ) if ( ! ( i % j )) b...
-
C中的do...while循环-C语言实例教程|
C中的do...while循环 #include stdio.h int main () { /* local variable definition */ int a = 10 ; /* do loop execution */ do { printf ( value of a: %d , a ); a = a + 1 ; } while (...
-
C中的for循环-C语言实例教程|
C中的for循环 #include stdio.h int main () { int a ; /* for loop execution */ for ( a = 10 ; a 20 ; a = a + 1 ){ printf ( value of a: %d , a ); } return 0 ; }...
-
c中的while循环-C语言实例教程|
c中的while循环 #include stdio.h int main () { /* local variable definition */ int a = 10 ; /* while loop execution */ while ( a 20 ) { printf ( value of a: %d , a ); a ++ ; } re...
-
嵌套switch语句-C语言实例教程|
嵌套 switch 语句 #include stdio.h int main () { /* local variable definition */ int a = 100 ; int b = 200 ; switch ( a ) { case 100 : printf ( This is part of outer switch , a )...
-
switch语句-C语言实例教程|
switch 语句 #include stdio.h int main () { /* local variable definition */ char grade = B ; switch ( grade ) { case A : printf ( Excellent! ); break ; case B : case C : printf ( W...
-
嵌套if语句-C语言实例教程|
嵌套 if 语句 #include stdio.h int main () { /* local variable definition */ int a = 100 ; int b = 200 ; /* check the boolean condition */ if ( a == 100 ) { /* if condition is tr...
-
If...elseif...else语句-C语言实例教程|
If...else if...else 语句 #include stdio.h int main () { /* local variable definition */ int a = 100 ; /* check the boolean condition */ if ( a == 10 ) { /* if condition is true th...
-
if...else语句-C语言实例教程|
if...else 语句 #include stdio.h int main () { /* local variable definition */ int a = 100 ; /* check the boolean condition */ if ( a 20 ) { /* if condition is true then print the ...