-----------------------------------------------------------------------------------------------------------
Previous Page Home Next Page Last Page
-----------------------------------------------------------------------------------------------------------
6.
What is the output of this C code (run without any commandline arguments)?
#include
int main(int argc, char *argv[])
{
while (*argv++ != NULL)
printf("%s\n", *argv);
return 0;
}
A. Segmentation fault/code crash
B. Executable file name
C. Depends on the platform
D. Depends on the compiler
Answer: A
--------------------------------------------------------------------------------------------------------
7.
In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision?
A. Yes
B. No
Answer: A
-------------------------------------------------------------------------------------------------------\
8.
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three
/* myprog.c */
int main(int argc, char **argv)
{
printf("%s", *++argv);
return 0;
}
A. myprog
B. one
C. two
D. three
Answer: B
---------------------------------------------------------------------------------------------------------
9.
If the different command line arguments are supplied at different times would the output of the following program change?
#include
int main(int argc, char **argv)
{
printf("%d", argv[argc]);
return 0;
}
A. Yes
B. No
Answer: B
------------------------------------------------------------------------------------------------------------
Previous Page Home Next Page Last Page
------------------------------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case
Printf
Variables
File Handling
Strings
Previous Page Home Next Page Last Page
-----------------------------------------------------------------------------------------------------------
6.
What is the output of this C code (run without any commandline arguments)?
#include
int main(int argc, char *argv[])
{
while (*argv++ != NULL)
printf("%s\n", *argv);
return 0;
}
A. Segmentation fault/code crash
B. Executable file name
C. Depends on the platform
D. Depends on the compiler
Answer: A
--------------------------------------------------------------------------------------------------------
7.
In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision?
A. Yes
B. No
Answer: A
-------------------------------------------------------------------------------------------------------\
8.
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three
/* myprog.c */
int main(int argc, char **argv)
{
printf("%s", *++argv);
return 0;
}
A. myprog
B. one
C. two
D. three
Answer: B
---------------------------------------------------------------------------------------------------------
9.
If the different command line arguments are supplied at different times would the output of the following program change?
#include
int main(int argc, char **argv)
{
printf("%d", argv[argc]);
return 0;
}
A. Yes
B. No
Answer: B
------------------------------------------------------------------------------------------------------------
Previous Page Home Next Page Last Page
------------------------------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case
Printf
Variables
File Handling
Strings