Programming Questions

Q:

What will be output of following c code?

#include <stdio.h>
int main()

{
    int x=123;
    int i={
         printf("c" "++")
    };
    for(x=0;x<=i;x++){
         printf("%x ",x);
    }
    return 0;

}

Answer

Output: c++0 1 2 3

Explanation: First printf function will print: c++ and return 3 to variable i.For loop will execute three time and printf function will print 0, 1, 2 respectively.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

63 44449
Q:

Which of the following is not a valid escape code?

A) " B) \
C) ' D) =
 
Answer & Explanation Answer: D) =

Explanation:

The valid escape codes in programming languages are ', ", \, n, or t are the valid escape codes. 

 

For example, the sequence \n usually represents a newline, while the escape sequence \\ represents a backslash, \t usually represents a newtab.

Report Error

View Answer Report Error Discuss

39 19065
Q:

main()

{

char s[ ] = "man";

int i;

for( i=0; s[ i ]; i++)

printf( "n%c%c%c%c", s[ i ], *(s+i), *(i+s), i[s] );

}

A) mmmm aaaa nnnn B) aaaa mmmm nnnn
C) nnnn aaaa mmmm D) None
 
Answer & Explanation Answer: A) mmmm aaaa nnnn

Explanation:

s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea.Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

Report Error

View Answer Report Error Discuss

Filed Under: Programming

24 27263
Q:

main()

{

char *p; p = "Hello";

printf ("%cn", *&*p);

}

A) H B) Hello
C) Compilation error D) H E L L O
 
Answer & Explanation Answer: A) H

Explanation:

* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H

Report Error

View Answer Report Error Discuss

Filed Under: Programming
Job Role: Software Architect

19 31130
Q:

Write a quick script for launching a new activity within your application.

Answer

An explicit intent explicitly defines the activity the developer wishes to start. 


Script code :


Intent myIntent = new Intent(this, MyNewActivity.class);


startActivity(myIntent);

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

15 4572
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 10065
Q:

#define clrscr() 100

main()

{

clrscr();

printf( "%dn", clrscr() );

}

A) 100 B) 0
C) Compilation error D) Exception occurs
 
Answer & Explanation Answer: A) 100

Explanation:

Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :

main ()

{

100;

printf("%d\n",100);

}

Note: 100; is an executable statement but with no action. So it doesn't give any problem.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

13 23148
Q:

Macro flowchart is also called as

A) Less Detail flowchart B) More detail flowchart
C) Simple detailed flowchart D) None of the above
 
Answer & Explanation Answer: A) Less Detail flowchart

Explanation:

A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task.

Macro flowchart shows the outlines the main segments of program. Macro flowchart is also called as less detail flowchart.

Report Error

View Answer Report Error Discuss

Filed Under: Programming
Exam Prep: AIEEE , Bank Exams , CAT , GATE , GRE
Job Role: Analyst , Bank Clerk , Bank PO

12 8696