Programming Questions

Q:

What will be output of following program?


#include <stdio.h>
int main()

{
   void (*p)();
   int (*q)();
   int (*r)();
   p = clrscr;
   q = getch;
   r = puts;
  (*p)();
  (*r)("www.sawaal.com");
  (*q)();
  return 0;
}

A) NULL B) www.sawaal.com
C) Compilation error D) None of above
 
Answer & Explanation Answer: B) www.sawaal.com

Explanation:

p is pointer to function whose parameter is void and return type is also void. r and q is pointer to function whose parameter is void and return type is int . So they can hold the address of such function.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 10421
Q:

If the following program (myprog) is run from the command line as 

myprog 1 2 3 

what would be the output?

main(int argc, char *argv[])

{

    int i, j = 0;

    for (i = 0; i < argc ; i++)

           j = j + atoi ( argv[i]);

    printf ("%d", j);

}

A) 123 B) 6
C) Error D) "123"
 
Answer & Explanation Answer: B) 6

Explanation:

When atoi() tries to convert argv[0] to a number it cannot do so (argv[0] being a file name) and hence returns a zero.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 10339
Q:

What would be the output of the following program ?

main() 

{

       unsigned  int a = oxffff;

        ~a;

        printf ("%x", a);

}

A) ffff B) 0000
C) 00ff D) None of the above
 
Answer & Explanation Answer: A) ffff

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

0 10256
Q:

What is the output of this C code?

        #include <stdio.h>
        void main()
        {
            int y = 3;
            int x = 5 % 2 * 3 / 2;
            printf("Value of x is %d", x);
        }

A) Value of x is 1 B) Value of x is 2
C) Value of x is 3 D) Compile time error
 
Answer & Explanation Answer: A) Value of x is 1

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 10168
Q:

The output of the code below is

        #include <stdio.h>
        int *m()
        {
            int *p = 5;
            return p;
        }
        void main()
        {
            int *k = m();
            printf("%d", k);
        }

A) 5 B) Junk value
C) 0 D) Error
 
Answer & Explanation Answer: A) 5

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

1 10001
Q:

A source program is the program written in which level language  ?

A) Alpha Numeric B) High-Level
C) Symbolic D) Machine
 
Answer & Explanation Answer: B) High-Level

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming
Exam Prep: Bank Exams
Job Role: Analyst , Database Administration , IT Trainer

14 9964
Q:

 What is the output of this C code? 

        #include <stdio.h>
        void m()
        {
            printf("hi");
        }
        void main()
        {
            m();
        }

A) hi B) Run time error
C) None D) Varies
 
Answer & Explanation Answer: A) hi

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

0 9434
Q:

A function cannot be defined inside another function

A) TRUE B) FALSE
Answer & Explanation Answer: A) TRUE

Explanation:

A function cannot be defined inside the another function, but a function can be called inside a another function.

Report Error

View Answer Workspace Report Error Discuss

Subject: Programming

5 8531