Embedded C Basic Questions for Job Interview and Lab Examination (Viva Tips) Part - I

Q. What does the keyword const mean? What do the following declarations mean?

const int a;
int const a;
const int *a;
int * const a;
int const * a const;

The first two mean the same thing, namely a is a const (read-only) integer.

The third means a is a pointer to a const integer (that is, the integer isn’t modifiable, but the pointer is).

The fourth declares a to be a const pointer to an integer (that is, the integer pointed to by a is modifiable,but the pointer is not).

The final declaration declares a to be a const pointer to a const integer
(that is, neither the integer pointed to by a, nor the pointer itself may be modified).
-------------------------------------------------- 


Q. Can a parameter be both const and volatile ? Explain.

Yes. An example is a read-only status register. It is volatile because it can change unexpectedly. It is const because the program should not attempt to modify it
-------------------------------------------------- 


Q.Can a pointer be volatile ? Explain.

Yes, although this is not very common. An example is when an interrupt service routine modifies a pointer to a buffer
--------------------------------------------------
Q. Why is sizeof(‘a’) not 1?Perhaps surprisingly, character constants in C are of type int, so sizeof(‘a’) is sizeof(int) (though it’s different in C++). 


Result:
In Turbo C output is: 2
In Turbo C++ output is: 1
-------------------------------------------------- 


Q. why n++ executes faster than n+1?

The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas, n+1 requires more instructions to carry out this operation.




More Embedded C Programming Questions And Suitable Answers:

Difference Between Process and Thread

What happens When Interrupt Occurs
Differences between Mutex And Semaphore
Unions-Why And When To Use
What is Storage class
C Programming Questions for Job Interview
Embedded C Programming Basic Questions for Job Interview
Data Declarations And qualifiers
Variables and Pointers Volatile Or Costant
Dangling and Wild Pointers

Related

Interview Questions 2990624776559091415

Post a Comment

  1. Tks very much for your post.

    Avoid surprises — interviews need preparation. Some questions come up time and time again — usually about you, your experience and the job itself. We've gathered together the most common questions so you can get your preparation off to a flying start.

    You also find all interview questions at link at the end of this post.

    Source: Interview Questions & Answers:

    Best rgs

    ReplyDelete
    Replies
    1. Thanks Kix for Your comment.We believe in healthy back-links so we moderate comments.

      Delete

SPAMMING will not be Appreciated.

emo-but-icon

Hot in week

Recent

Comments

Our Channel

Contact Us

Name

Email *

Message *

Follow by Email

item