Welcome Guest | Sign in | Register

Home > C Programming > Arrays > Questions and Answers

01. Use a printf statement to print out the contents of the character array called words
A. printf("%s\n", words); B. printf("%c\n", words);
C. printf("%d\n", words); D. printf("%s\n", words[2]);

Answer and Explanation

Answer: printf("%s\n", words);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. Use a scanf statement to read a string of characters into the array words.
A. scanf("%s\n", words); B. scanf(" %c", words);
C. scanf("%c", words); D. scanf("%s", words);

Answer and Explanation

Answer: scanf("%s", words);

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. Write for loop which will read five characters (use scanf) and deposit them into the character based array words, beginning at element 0.
A. Statement 1
for( loop = 0; loop < 5; loop++ )
scanf("%c", &words[loop] );
B. Statement 2
for( loop = 0; loop <= 5; loop++ )
scanf("%c", words );
C. Statement 3
for( loop = 0; loop < 5; loop++ )
scanf("%c", &words[0] );
D. Cannot be detemined

Answer and Explanation

Answer: Statement 1
for( loop = 0; loop < 5; loop++ )
scanf("%c", &words[loop] );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What will be printed as the result of the operation below?
main()
{
char s1[]="Cisco"
char s2[]= "systems";
printf("%s",s1);
}
A. system B. error
C. Cisco D. Compilation fail

Answer and Explanation

Answer: Cisco

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. What will be output if you will execute following c code?
#include
int main(){
char arr[7]="Network";
printf("%s",arr);
return 0;
}  
A. Network B. N
C. network D. Garbage value
E. Compilation error

Answer and Explanation

Answer: Garbage value

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What will be output if you will execute following c code?

#include
int main(){
char arr[20]="MysticRiver";
printf("%d",sizeof(arr));
return 0;
}  
A. 20 B. 11
C. 12 D. 22
E. 24

Answer and Explanation

Answer: 20

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What will be output when you will execute following c code?
#include
enum power{ Dalai, Vladimir=3, Barack, Hillary };
int main(){
float leader[Dalai+Hillary]={1.f,2.f,3.f,4.f,5.f};
enum power p=Barack;
printf("%0.f",leader[p>>1+1]);
return 0;
}  
A. 1 B. 2
C. 3 D. Compilation error
E. None of the above

Answer and Explanation

Answer: 2

Explanation:
Size of an array can be enum constantan. Value of enum constant Barack will equal to Vladimir + 1 = 3 +1 = 4 So, value of enum variable p = 4 leader[p >> 1 +1] = leader[4 >> 1+1] =leader[4 >> 2] //+ operator enjoy higher precedence than >> operator. =leader[1] //4>>2 = (4 / (2^2) = 4/4 = 1 =2

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. What will be output when you will execute following c code?
01 #include
02 #define var 3
03 int main()
04 {
05 char *cricket[var+~0]={"clarke","kallis"};
06 char *ptr=cricket[1+~0];
07 printf("%c",*++ptr);
08 return 0;
09 }
A. a B. r
C. l D. Compilation error
E. None of the above

Answer and Explanation

Answer: l

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
A. The element will be set to 0 B. The compiler would report an error
C. The program may crash if some important data gets overwritten D. The array size would appropriately grow

Answer and Explanation

Answer: The program may crash if some important data gets overwritten

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What string does ptr point to in the sample code below?
Code:
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
A. fg B. efg
C. defg D. cdefg
E. Choice 5

Answer and Explanation

Answer: fg

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.