Q.1

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<stdio.h>
#include<stdlib.h>

int main(int argc, char **argv)
{
    printf("%s\n", *++argv);
    return}
  • myprog
  • one
  • two
  • three
Q.2

Which of the following statements are FALSE about the below code?

int main(int ac, char *av[])
{
}
  • ac contains count of arguments supplied at command-line
  • av[] contains addresses of arguments supplied at a command line
  • In place of ac and av, argc and argv should be used.
  • The variables ac and av are always local to main()
Q.3

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}
  • r
  • f
  • m
  • y
Q.4

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}
  • s
  • f
  • u
  • r
Q.5

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>        printf("%s", *++argv);
    return}
  • sample monday tuesday wednesday thursday
  • monday tuesday wednesday thursday
  • monday tuesday thursday
  • tuesday
Q.6

What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)?
cmd> sample 1 2 3

/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    int j;
    j = argv[+ argv[+ argv[3];
    printf("%d", j);
    return}
  • 6
  • sample 6
  • Error
  • Garbage value
Q.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=    i+=strlen(argv[1]);
    while(i>    {
        printf("%c", argv[1][--i]);
    }
    return}
  • three two one
  • owt
  • eno
  • eerht
Q.8

What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog30

/* myprog.c */
#include<stdio.h>

int main(int argc, char **argv)
{
    int i;
    for(i=i<argc; i++)
        printf("%s\n", argv[i]);
    return}
  • 10 20 30
  • myprog 10 20
  • myprog 10 20 30
  • 10 20
Q.9

If the following program (myproc.c) is present in the directory "C:\TC" then what will be output of the program if run it from DOS shell?

/* myproc.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%s", argv[0]);
    return}
  • SAMPLE.C
  • C:\TC\MYPROC.EXE
  • C:\TC
  • Error
Q.10

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}
  • 3 Good
  • 2 Good
  • Good Morning
  • 3 Morning
Q.11

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<stdio.h>

int main(int argc, char *argv[])
{
    int i;
    for(i=i<argc; i++)
        printf("%c", argv[i][0]);
    return}
  • oot
  • ott
  • nwh
  • eoe
Q.12

What will be the output of the program

#include<stdio.h>
void fun(int);

int main(int argc)
{
    printf("%d ", argc);
    fun(argc);
    return}
void fun(int i)
{
    if(i!=        main(++i);
}
  • 1 2 3
  • 1 2 3 4
  • 2 3 4
  • 1
0 h : 0 m : 1 s