1-
|
What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%d %s", argc, argv[1]);
return 0;
}
|
|
A -
|
3 Good
|
|
B -
|
2 Good
|
|
C -
|
Good Morning
|
|
D -
|
3 Morning
|
2-
|
What will be the output of the program #include<stdio.h>
void fun(int);
int main(int argc)
{
printf("%d\n", argc);
fun(argc);
return 0;
}
void fun(int i)
{
if(i!=4)
main(++i);
}
|
|
A -
|
1 2 3
|
|
B -
|
1 2 3 4
|
|
C -
|
2 3 4
|
|
D -
|
1
|
3-
|
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample "*.c"
/* sample.c */
#include<stdio.h>
int main(int argc, int *argv)
{
int i;
for(i=1; i<argc; i++)
printf("%s\n", argv[i]);
return 0;
}
|
|
A -
|
*.c
|
|
B -
|
"*.c"
|
|
C -
|
sample *.c
|
|
D -
|
List of all files and folders in the current directory
|
4-
|
What will be the output of the program if it is executed like below?
cmd> sample
/* sample.c */
#include<stdio.h>
int main(int argc, char **argv)
{
printf("%s\n", argv[argc-1]);
return 0;
}
|
|
A -
|
0
|
|
B -
|
sample
|
|
C -
|
samp
|
|
D -
|
No output
|
5-
|
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<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", **++argv);
return 0;
}
|
|
A -
|
s
|
|
B -
|
f
|
|
C -
|
sample
|
|
D -
|
friday
|
6-
|
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[1]);
return 0;
}
|
|
A -
|
r
|
|
B -
|
f
|
|
C -
|
m
|
|
D -
|
y
|
7-
|
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample one two three
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
int i=0;
i+=strlen(argv[1]);
while(i>0)
{
printf("%c", argv[1][--i]);
}
return 0;
}
|
|
A -
|
three two one
|
|
B -
|
owt
|
|
C -
|
eno
|
|
D -
|
eerht
|
8-
|
What will be the output of the program in Turbo C?
#include<stdio.h>
int main(int argc, char *argv, char *env[])
{
int i;
for(i=1; i<argc; i++)
printf("%s\n", env[i]);
return 0;
}
|
|
A -
|
List of all environment variables
|
|
B -
|
List of all command-line arguments
|
|
C -
|
count of command-line arguments
|
|
D -
|
Error: cannot have more than two arguments in main()
|
9-
|
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample Jan Feb Mar
/* sample.c */
#include<stdio.h>
#include<dos.h>
int main(int arc, char *arv[])
{
int i;
for(i=1; i<_argc; i++)
printf("%s ", _argv[i]);
return 0;
}
|
|
A -
|
No output
|
|
B -
|
sample Jan Feb Mar
|
|
C -
|
Jan Feb Mar
|
|
D -
|
Error
|
10-
|
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample monday tuesday wednesday thursday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
while(--argc>0)
printf("%s", *++argv);
return 0;
}
|
|
A -
|
sample monday tuesday wednesday thursday
|
|
B -
|
monday tuesday wednesday thursday
|
|
C -
|
monday tuesday thursday
|
|
D -
|
tuesday
|