logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • Give an example for the use of volatile keyword in c++ ?


  • Correct Answer
  • Most of the times compilers will do optimization to the code to speed up the program For example in the below code, int k = 15; while( k == 15) { // Do something } compiler may think that value of 'k' is not getting changed in the program and replace it with 'while(true)', which will result in an infinite loop In actual scenario, the value of 'k' may be getting updated from outside of the program Volatile keyword is used to tell compiler that the variable declared using 'volatile' may be used from outside the current scope, so that compiler won't apply any optimization This matters only in case of multi-threaded applications In the above example if variable 'k' was declared using volatile, compiler will not optimize it In shot, value of the volatile variables will be read from the memory location directly 

  • Tags: IT Trainer, Project Manager, Software Architect

    Technology problems


    Search Results


    • 1. Which of the following type casts will convert an Integer variable named amount to a Double type ?

    • Options
    • A. (int to double) amount
    • B. int (amount) to double
    • C. int to double(amount)
    • D. (double) amount
    • Discuss
    • 2. Which design patterns benefit from the multiple inheritance?

    • Options
    • A. Adapter and observer pattern
    • B. Code pattern
    • C. Glue pattern
    • D. None of these
    • Discuss
    • 3. How many types of modularization are there in c++?

    • Options
    • A. 4
    • B. 3
    • C. 1
    • D. none of these
    • Discuss
    • 4. Which of the following is a properly defined structure?

    • Options
    • A. struct {int a;}
    • B. struct a_struct {int a;}
    • C. struct a_struct int a;
    • D. struct a_struct {int a;};
    • Discuss
    • 5. In HTML document the tags are

    • Options
    • A. hidden keywords
    • B. used to display the content
    • C. Both A & B
    • D. None of the above
    • Discuss
    • 6. Which of the following is not a correct variable type?

    • Options
    • A. real
    • B. char
    • C. float
    • D. double
    • Discuss
    • 7. What are the tasks of a Business Analyst in Software Development Life Cycle?
    • Discuss
    • 8. Define what is a Fact, Dimension and Measure ?
    • Discuss
    • 9. What is the difference between ADODC and ADODB?
    • Discuss
    • 10. What is the diff between RDO and ADO?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment