To use command line arguments in C++, how many parameters are passed to the main function?
Answer: B
2 arguments are needed to be passed to main() function while using command line arguments. The first one represents a number of strings in the argument list and the second list represents the list of string arguments.
Enter details here
What is the output of this C code?
#include
int main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
}
Answer: D
No answer description available for this question.
Enter details here
What is argv[0] in command line arguments?
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include
int main(int argc, char *argv[])
{
printf("%c", **++argv);
return 0;
}
Answer: B
No answer description available for this question.
Enter details here
What will be the output of this program ?
Answer: A
No answer description available for this question.
Enter details here
What is the output of this C code?
#include
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int *j = (int*)malloc(sizeof(int));
*j = 10;
return j;
}
Answer: A
No answer description available for this question.
Enter details here
Which of the following is correct about the first parameter of the main function?
Answer: D
All of the statements about the first parameter is correct. The first parameter is of non-negative integer type and stores the count of command line arguments.
Enter details here
What is the output of this C code?
#include
int main()
{
int i = 97, *p = &i;
foo(&i);
printf("%d ", *p);
}
void foo(int *p)
{
int j = 2;
p = &j;
printf("%d ", *p);
}
Answer: A
No answer description available for this question.
Enter details here
A program that has no command line arguments will have argc _________
Answer: C
No answer description available for this question.
Enter details here
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 */
#include
int main(int argc, char **argv)
{
printf("%c\n", **++argv);
return 0;
}
Answer: C
No answer description available for this question.
Enter details here