Welcome Guest | Sign in | Register

Home > C Programming > Functions > Questions and Answers

01. Which of the following is a valid function call (assuming the function exists)?
A. funct B. funct x, y;
C. funct(); D. int funct();

Answer and Explanation

Answer: funct();

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. Which of the following is a complete function?
A. int funct(); B. int funct(int x) {return x=x+1;}
C. void funct(int) { printf( "Hello"); D. void funct(x) { printf( "Hello"); }

Answer and Explanation

Answer: int funct(int x) {return x=x+1;}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. The function called menu which prints the text string "Menu choices", and does not pass any data back, and does not accept any data as parameters, looks like
A. function 1
void menu( void ) {
printf("Menu choices");
}
B. function 2
int menu( void ) {
printf("Menu choices");
}
C. function 3
int menu( char string[] ) {
printf("%s", string);
}
D. Cannot be determined

Answer and Explanation

Answer: function 1
void menu( void ) {
printf("Menu choices");
}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. A function prototype for the above function looks like
A. int menu( char [] ); B. void menu( char [] );
C. void menu( void ); D. int menu( void );

Answer and Explanation

Answer: void menu( void );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. A function called print which prints a text string passed to it as a parameter (ie, a character based array), looks like
A. function 1
int print( char string[] ) {
printf("%s", string);
}
B. function 2
void print( char string[] ) {
printf("Menu choices");
}
C. function 3
void print( char string[] ) {
printf("%s", string);
}
D. Cannot be determined

Answer and Explanation

Answer: function 3
void print( char string[] ) {
printf("%s", string);
}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. A function prototype for the above function print looks like
A. int print( char [] ); B. void print( char [] );
C. void print( void ); D. int print( void );

Answer and Explanation

Answer: void print( char [] );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. A function called total, totals the sum of an integer array passed to it (as the first parameter) and returns the total of all the elements as an integer. Let the second parameter to the function be an integer which contains the number of elements of the array.
A. function 1
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop < elements; loop++ )
total = total + numbers[loop];
return total;
}
B. function 2
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop <= elements; loop++ )
total = total + numbers[loop];
return total;
}
C. function 3
int total( int numbers[], int elements ) {
int total, loop;
for( loop = 0; loop > elements; loop++ )
total = total + numbers[loop];
return total;
}
D. None of these

Answer and Explanation

Answer: function 1
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop < elements; loop++ )
total = total + numbers[loop];
return total;
}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. How many times main() will get called?
main()
{
printf("\n Main Called Again");
main();
}
A. 1 B. 100
C. main cannot be called recursively D. Infinite

Answer and Explanation

Answer: Infinite

Explanation:
There is no condition in the main() to stop the recursive calling of the main() hence it will be called infinite no of times.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What is the output of the following code?
#include "stdio.h"
extern int a=5;
main(){
void fun();
printf("\n a=%d",a);
fun();
return 0;
}
int a;
void fun(){
printf("\n in fun a=%d",a);
}
A. a=0 in fun a=5 B. a=5 in fun a=0
C. a=5 in fun a=5 D. error

Answer and Explanation

Answer: a=5 in fun a=5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
void fun();
printf("\n a=%d",a);
fun();
return 0;
}
int a=7;
void fun(){
printf("\n in fun a=%d",a);

A. a=0 in fun a=0 B. a=7 in fun a=7
C. a=7 in fun a=0 D. error

Answer and Explanation

Answer: a=7 in fun a=7

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.