1.Which of the following will produce true only if the character cis either a digit or an upper case English letter? (c >= 0 && c <= 9) || (c >= A && c<= Z) (c >= 0 && c <= 9) || (c >= ‘A’ && c<= ‘Z’) (c >= ‘0’ && c <= ‘9’) || (c >= ‘A’ && c<= ‘Z’) (c >= ‘0’ && c <= ‘9’) && (c >= ‘A’ && c<= ‘Z’) 2.Performing a = upper(c)on a variable that is known to contain a character from 'a' to 'z' is the same as: a = c +’a’-‘A’; a = c +’A’- ‘a’ a = c – ‘A’; a = c – ‘a’;
1.Which of the following will produce true only if the character cis either a digit or an upper case English letter?
-
- (c >= 0 && c <= 9) || (c >= A && c<= Z)
- (c >= 0 && c <= 9) || (c >= ‘A’ && c<= ‘Z’)
- (c >= ‘0’ && c <= ‘9’) || (c >= ‘A’ && c<= ‘Z’)
- (c >= ‘0’ && c <= ‘9’) && (c >= ‘A’ && c<= ‘Z’)
2.Performing a = upper(c)on a variable that is known to contain a character from 'a' to 'z' is the same as:
-
- a = c +’a’-‘A’;
- a = c +’A’- ‘a’
- a = c – ‘A’;
- a = c – ‘a’;
3.Which of the following will read a string from a file with FILE* fpto char myString[81] properly (safely):
-
- fscanf(fp, "%s", myString );
- fgets(myString, fp);
- fgets(fp, 81, myString); correct : fgets(myString, 81,fp)
- fscanf(fp,"%80s", myString);
4.If you issue the statement fpIn = fopen("myfile.dat", "a");and dat does not exist, the computer will:
-
- return NULLto fpIn as the file does not exist
- create the file in write mode, and position the file pointer at the beginning of the file
- create the file in write mode, close the file and return a warning
- open a file that most closely resembles the name 'myfile.dat'
5. How many bytes in the memory will be occupied by short int array[10]
-
-
- 10 Bytes
- 20 Bytes
- 40 Bytes
- 60 Bytes
-
6.Given the definition void myFunc(int a, int* b , int* c)which statement is true
-
- The values of the aliases a, band c are available to the function
- Only the addresses of the variables b, care available to the function
- myFunccannot change the variable whose value is copied to a
- myFunc can change the value of the variable whose address is copied into b
- all of the above
7Which of the following is a TRUE statement regarding the strcpy(char * str1, char * str2)function?
- It copies str2in str1 if str1 has enough space
- It adds str2to str1 making a long string
- It returns NULL if str1has a shorter length compared to str2
- It copies the terminating null after coping the characters from str2to str1
8.Give charstr[5]=" "; what is the value of *(str+1) = str[1]
9.What if I asked for *str + 1= str[0] + 1 = 32 + 1 = 33
Str[0]
32=’ ‘ 0
------ ------
- 1001
- 0
- ‘0’
- space
- unknown value
10.Give char str[15]="Hello World"; what is the value of
*str and *str+1
‘H’ , ‘H’ + 1
*str and *(str + 1)
- ‘H’ and ‘e’
- ‘H’ and ‘I’
- Address of first and second characters of the string
- ‘H’ and ‘f’
11.Defining char myString[10]=”IPC144” what is the value of
strlen( 1+ myString)
1+ strlen(myString) would be 7
-
- 10
- 5 -- correct
- 6
- 7
Step by step
Solved in 2 steps with 13 images