2 main ()
3 { float s[5];
4 int I,SZ = 0;
5 for(I = 0; I<5; I++)
6 scanf("%d ",s+I);
7 for(I = 0; I<5; I++)
8 SZ+= s[I];
9 printf("\n%f ",(float)SZ);
10 }
A) no mistakes
B) Error in line 4
C) Error in line 6
D) Error in line 9
C s array is a real number type and cannot be entered as an integer.
The following legal array definition is ().
a)int a[]= " string ";
B) int a[5]={0, 1,2,3,4,5 };
c)char a = " string ";
D) char a[]={0, 1,2,3,4,5 };
D.A.A. [] is not plastic. B. There are six elements. C is char a[]= "string ";; That's right.
The following program segment inputs the data of all elements of an array. Please select the correct answer and fill in ().
# include & ltstdio.h & gt
Master ()
{
int a[ 10],I = 0;
While (I< 10)
scanf(" % d " ,_ _ _ _ _ _);
}
A) a+(i++)
B) and amp[i+ 1]
C) a+i
D) and ampa[i++]
D AC is obviously wrong. B did not enter the value of a[0].
Equipped with:
Static char str[]= "Beijing";
Then execute:
printf("%d\n ",strlen(strcpy(str," China)));
The output result is ().
A) 5
B) 7
C) 12
D) 14
Strcpy is a string copying function, and strlen is a string statistics function.
Read the following program.
Master ()
{
inn[2],I,j,k;
for(I = 0; I<2; I++)
n[I]= 0;
k = 2;
for(I = 0; I & ltk;; I++)
for(j = 0; j & ltk; j++)
n[j]= n[I]+ 1;
printf("%d\n ",n[k]);
}
The output of the above program is ().
A) uncertain value
B) 3
C) 2
D) 1
There is something wrong with the topic
for(I = 0; I<2; I++)
n[I]= 0;
Initialize n[0], where n[ 1] is 0.
Four cycles
for(I = 0; I & ltk;; I++)
for(j = 0; j & ltk; j++)
n[j]= n[I]+ 1;
N[0]=3,n[ 1]=4。
printf("%d\n ",n[2]); N[2] itself is wrong and out of line.
Define the following variables and arrays:
int I;
int x[3][3]={ 1,2,3,4,5,6,7,8,9 };
The output of the following statement is (). for(I = 0; I<3; I++)
printf("%d ",x[I][2-I]);
A) 1 5 9
B) 1 4 7
C) 3 5 7
D) 3 6 9
A I = 0 output (0) (2) = 3, I = 1 output X (1) (1) = 5, I = 2 output X (2) (0) = 7.
If there are the following instructions:
int a[ 12]={ 1,2,3,4,5,6,7,8,9, 10, 1 1, 12 };
char c='a ',d,g;
The expression with a value of 4 is ().
a[g-c]
B) a[4]
C) a['d'-'c']
D) a['d'-c]
D A is an uncertain value, b gets 5, and c gets 2.
Printf("%d\n ",strlen(" \ t \ " \ 065 \ xff \ n));
A) 5
B) 14
C) 8
D) The output item is illegal and there is no normal output.
A has five escape characters.
\t horizontal tab
"double quotation marks
\065 Pentary Octal
Unknown character in \ xff 16. Print it out as a two-character space.
\n newline character
If there are the following definitions and statements:
char s[ 10];
s = " abcd
printf("%s\n ",s);
The output result is ().
A) output abcd
B) output a
Output abcd.
D) compilation failed.
D string cannot be negative; The address should be s [] = "ABCD";
The output of the following program is ().
# include & ltstdio.h & gt
Master ()
{
char ch[7]= { " 65ab 2 1 " };
int I,s = 0;
for(I = 0; ch[I]& gt; = ' 0 ' & amp& ampch[I]& lt; ='9'; I+=2)
s = 10 * s+ch[I]--0;
printf("%d\n ",s);
}
A) 12ba56
B) 652 1
C) 6
D) 62
C the first time ch[0]=6, the second time ch[2]=a jumps out of s=6.
In the following function references, () contains an error. Where s is defined as follows:
char s[ 10];
A) scanf("% 10s ",s);
B) printf("%.5s ",s);
Put option (S+3);
D) obtaining (s);
C If the string s[ 10] has only one character, such as a \0, then s[3] pointed by s+3 has no memory allocated.
Define the following arrays:
char s[40];
If you want to record the string "This is a string." , () is an incorrect input statement.
A) obtaining (s+2);
B) scanf("%20s ",s);
c)for(I = 0; I< 17; I++)
s[I]= getchar();
D) while((c=getchar())! ='\n ')
s[i++]= c;
This is a string. No input \n