Showing posts with label C FAQ's. Show all posts
Showing posts with label C FAQ's. Show all posts

Saturday, 24 August 2013

What is the difference between array and linked list - Simple and Easy to Rollout the topic


Memory in Arrays is indeed allocated in a continues manner, that is the reason why arrays can offer random access while linked lists cant.

Arrays are also called Dense lists or static data structures.

Friday, 23 August 2013

How many types of pointers in C

1.         NULL pointer?
A.        A null pointer has a value reserved for indicating that the pointer does not refer to a valid object. Null pointers  are routinely used to represent  conditions such as the end of a list of unknown length or the failure to perform some action

Null pointer in most programming languages means "no value", while null value in relational database means "unknown value".

            Example:       int *p=0;        or        int *p=NuLL;


2.         Based pointer?
A.        A based pointer is a pointer whose value is an offset from the value of another pointer. This can be used to store and load blocks of data, assigning  the address of the beginning of the block to the base pointer.

3.         wild branch?
A.        Wild pointers are pointers that have not been initialized (that is, a wild pointer has not had any address assigned to it) and may make a program crash or behave oddly. In the Pascal or C programming languages,     pointers that are not specifically initialized may point to unpredictable addresses in memory.
           
            The following example code shows a wild pointer:
                       
            int func(void)
            {
                char *p1 = malloc(sizeof(char)); /* (undefined) value of some place on the heap */
                char *p2;       /* wild (uninitialized) pointer */
                *p1 = 'a';      /* This is OK, assuming malloc() has not returned NULL. */
                *p2 = 'b';      /* This invokes undefined behavior */
            }         

4.         autorelative pointer?
A.       The term autorelative pointer may refer to a pointer whose value is interpreted as an offset from the address of the pointer itself; thus, if a data structure,
M, has an autorelative pointer member, p, that points to some portion of M itself, then M may be relocated in memory without having to update the value of p.                       
The cited patent also uses the term self-relative pointer to mean the same thing. However, the meaning of that term has been used in other ways:
It is often used to mean an offset from the address of a structure rather than from the address of the pointer itself.
It has been used to mean a pointer containing its own address, which can be useful for reconstructing in any arbitrary region of memory a collection of data structures that point to each other.

5.         Void Pointers?
A.        Void pointer is generic pointer that can point to any data type.It can hold the base address of another pointer data variable.
                       
            syntax void *vpt;


            int *ptr=&a;


6.         DANGLING POINTER?     
Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. As the system may reallocate the previously freed memory to another process, if the original program then dereferences the (now) dangling pointer, unpredictable behavior may result, as the memory may now contain completely different data. This is especially the case if the program writes data to memory pointed by a dangling pointer, a silent corruption of unrelated data may result, leading to subtle bugs that can be extremely difficult to find, or cause    segmentation faults (*NIX) or general protection faults (Windows). If the overwritten data is bookkeeping data used by the system's memory allocator, the corruption can cause system instabilities.

            

Friday, 9 August 2013

FAQ' s on C Language - Embedded Trainees have to know all this


1. what is "little endian" and "big endian" and how to know this?

2. Is it possible to specify width of the data in strings? how? and what happens when that exceded or reduced

3. what are the "unary operators?"

4. Is it possible to assaign a value to a variable before declaring?

5. can you write an inline code for finding largest of three numbers using ternary operator?

6. what is inline function in c?

7. write a program for '/' and '%' operators without using them.

8. Difference between return and goto functions

9. write a program to print pascal triangle

10. where main function return will go

11. where function declarations are present

12. who calls the main() function

13. Difference between recursion and iteration

14. Is it possible to multiply or division of two pointers?what are
the arithmetic operations supported in pointers

15. Difference between pointer to an array and array of pointers

16. How to access last element of the following expression using pointers
a[l][m][n][o][p][q][r]

17. How to return more than one value from a function? program

18. Difference between switch and function pointers

19. what is the use of sprintf() and sscanf() functions

20. Difference between structure and unions .

21. Difference between structure and arrays.

22. "I Love my India, I Love my Country"..write a program that prints how many times that each word occures using pointers
like: I:2 Love:2 my:2 India:1 ,:1 Country:1 <space>:7

23. what is the size of structure when declaring

24. why padding occurs in structures how to reduce it

25. Difference between typedef and #define

26. write a program that accepts input from STDIN and output must be like this...
every line contains exactly 72 characters
if more try to fix in another line
if less fill with spaces

27. Difference between MACRO and FUNCTION

28. What happens in preprocessor stage

29. Using command line arguments take the following input:
like: 10+24$ -34&54+ p54-22
and output must be 10+24-34-22=-22
means remove extra symbols otherthan +,-,*,/,% and consider only values who has prefix these symbols

30. How to mask or unmask bits

31. what is the use of bit fields

32. Difference between enum and #define

33. Difference between static and extern

34. Difference between local static and global static

35. Is it possible to use global static functions in another file

36. Is it possible to declare the global static function in header files to access in only one function

37. what is file scope

38. write a program for the predefine function atoi()

39. return type of malloc write general syntax for it

40. sizeof double pointer

Wednesday, 17 July 2013

DATA PATTERNS INTERVIEW EXPERIENCE - July 2013 | Interview Questions

Interview process is very friendly they check how perfect your are in the concepts

SELECTION PROCESS:

Written test: c (20 questions) and aptitude (20 questions)

Technical round 1:


In first Technical Round they will check basics in
  • C & Data Structures 
  • OS concepts 
  • Micro controller.
Sample Questions: 
  1. What is dead lock?explain with example
  2. What is critical section
  3. What is IPC
  4. Difference b/w pipe and message queue
  5. About exit system call.
C questions:
  1. Wap linked list creation and deletion of node?explain?
  2. What is self referential structure and write it?
  3. Sizeof(void)
  4. Explain about bitwise operators?
  5. What is the use of #include and #define?
  6. Tell me some header files?purpose?
  7. Dynamic memory allocation?write prototype of malloc function?
  8. Wap to test the 7th bit in given hex decimal number using bitwise operators?
  9. Wap to swap 2 numbers using temp variable and without using temp?
Technical round 2:
  1. How much you rate in C?
  2. Programming on linked list?
  3. What is binary tree?
  4. a*b-c+d/e from this expression draw a binary tree and traverse the above in pre-order, post order and in-order?
  5. Sizeof int is architectural dependent or compiler dependent?
  6. Micro controller architecture?
  7. Write client sever program?
  8. Write structure using bit fields?
  9. Wap to Fibonacci series using recursive function?explain?

HR round:
  1. Tell me about your self?
  2. About the company?
  3. What is your goals?
  4. Tell me about your family?
  5. Who is your idle person and why?
  6. If your previous year passed out candidate they ask you the reason for the gap?
  7. If u want to change one thing in your life what is that?
  8. How to prepare for your exams?

NCR Corporation Interview Process - Held on July 2013 | NCR Corporation Interview Questions


Written test: 

It includes 4 section that covered the following topics
  • C output of programs
  • writing programs in C
  • English section
  • logical question section.
Group discussion : 

There were general topics given followed by 2 min self introduction round.

1st Technical round:

Focused on CPP, questions  like
  1. What are access specifier?
  2. Explain constructor, destructor, friend class,static class , exception handling?
And from C  
Write a program to explain the
  1. Structure concept
  2. Difference between structure and enum
  3. Dynamic memory allocation
  4. Some networking question and project.

2nd technical and HR interview: 
  1. Asked some question on CPP, dynamic library (.dll), link list question, debugging technique,project explanation. 
  2. HR question were like if you are kept in a room for 6 to 7 hr what will you do?, 
  3. If you have deadline for a work and a friend came  for help then  what will you do?, 
  4. Real time example of team work, 
  5. Best moment in life, 
  6. Turnoff time in your life,hobbies etc..

Friday, 17 May 2013

Sedots Placement Papers and Interview Questions


1.
main()
{
int a=2,b=3,c=4;
printf(“%d%d%d”);
}


2.
static int i=25;
Static int i;
main()
{
Static int i;
printf(“%d”,i);
}


3.
struct bitone
{
Int a:3;
Int b:13;
Int c:1;
}bit1;
main()
{
printf(“%d”,sizeof(bit1));
}


4.
main()
{
char *str=NULL;
strcpy(str,”an”);
printf(“str);
}


5.
main()
{
arr[5]={1,2,3,4,5};
printf(“%d”,-2[arr]);
}


6.
main()
{
 char c=’\08’;
printf(“%d”,c);
}


 7.
main()
{
If(0.001-0.1f)
{
printf(“yes\n”);
}
else
{
printf(“No”);
}
}


8.
main()
{
int a=2;
a=˜a+2<<1;
printf(“%d”,a);
}

Technical Questions:

1.Write a program to calculate the size of the structure with out using sizeof?
2.write a program to print your name with out using conditional statements and conditional operators?
3.write a program to calculate sum of the individual digits until it becomes one digit?
(ex:123456 sum is 21 and 21 sum is 3)
4.project description
5.what is virtual pointer
6.program for 7 segment display
7.what is the purpose of constructor
8.diffrences between spi and i2c protocols
9.diffrence between make and make –f
10.what is oops concept

Thursday, 1 November 2012

CISCO 2012 Placement papers | cisco placement papers 2012 pattern | cisco placement papers with answers


CISCO: 2012: Sept at Chennai





 There were almost 40 technical questions and 10 analytical questions. Total 50 questions.



Cisco Placements Technical questions :

1. Which of the following is connectionless protocol

Ans: UDP(User Datagram Protocol)

2.

 #define clrscr() 100

main()

{

clrscr();

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

}

3. Which of the following is used for avoiding network congestion

buffering

caching

source-quench

all of the above

4. main()

{

int a;

printf("%d",scanf(%d,&a));

}

whats o/p of this program..what will b printed

Ans :0

5.

main()

{

printf("as");

printf("\bhi");

printf("is\n");

}

wat will b printed.

6.

main()

{

unsigned short a=-1;

unsigned char b=a;

printf("%d %d ",a,b);

}

wat is o/p of the program

a. 65535 -1 b. 65535 65535 c. -1 -1

7. Arrays base address is 1000....array is a[5][4]..then wat is de

correct address of a[4][3].

Ans:1056

8. One packet is 64 bytes no. of pkts send is 16000 then total no. of bytes send is

Ans 1024000

9. #define maxval 5

int main (void)

{

int i=1;

if(i-maxval)

{

printf("inside");

}

else

{

printf("out");

}

find o/p???

10.

#define a 3+3

#define b 11-3

main()

{

printf("%d",a*b);

}

what is o/p?????

11. A question in which segment address is given logical address is 800 base addresses also given you have to find physical address.

12. Stack is used in a task

Ans: temporary variables values

13. Which of de following is not stored in activation record..

Ans: some heap area

14. main{

printf("%d",-1<<4); } wats o/p??? ans: 0xfff0

15. main() { int* s s=10 printf("%d,%d,%d,%d,%d,%d",*s++,(*s)++,++*s,++(*s)); } whats o/p?

16. There was a question on processor speed in nanocycles..then it performs a instruction in x cycles..dont remember

17. main() { int *i; int s=(int *)malloc(10*sizeof(int)); for (i=0;i<10;i++) { printf("%d",i*i) } wats o/p

18. One more similar question Cisco  Conducted On   Computer awareness test.

1. In the command scanf, h is used for

Ans. Short int

2. A process is defined as

Ans. Program in execution

3. A thread is

Ans. Detachable unit of executable code.

4. What is the advantage of Win NT over Win 95

Ans. Robust and secure

5. How is memory management done in Win95

Ans. Through paging and segmentation

6. What is meant by polymorphism

Ans. Redefinition of a base class method in a derived class

7. What is the essential feature of inheritance

Ans. All properties of existing class are derived

8.What does the protocol FTP do

Ans. Transfer a file b/w stations with user authentication

9.In the transport layer ,TCP is what type of protocol

Ans. Connection oriented

10.Why is a gateway used

Ans. To connect incompatible networks

11.How is linked list implemented

Ans. By referential structures

12.What method is used in Win95 in multitasking

Ans. Non preemptive check

13.What is meant by functional dependency

14.What is a semaphore

Ans. A method synchronization of multiple processes

15.What is the precedence order from high to low ,of the symbols ( ) ++ /

Ans.( ) , ++, /

16.Preorder of A*(B+C)/D-G Ans.*+ABC/-DG

18. B-tree (failure nodes at same level)

19. Dense index (index record appears for every search -key in file)

20.What is the efficiency of merge sort

Ans. O(n log n)

21.A program on swapping ( 10,5 )was given (candidate cannot recollect)

22.In which layer are routers used

Ans.In network layer 23.In which layer are packets formed ( in network layer )

24. heap ( priority queue )

25. Copy constructor ( constant reference )

26.Which of the following sorting algorithm has average sorting behavior,  Bubble sort, merge sort, heap sort, exchange sort

Ans. Heap sort

27.In binary search tree which traversal is used for getting ascending order values Inorder, post order, preorder Ans. In-order

28.What are device drivers used for

Ans.To provide software for enabling the hardware

29. Irrelevant to UNIX command ( getty)

30.What is fork command in UNIX

Ans. System call used to create process

31.What is make command in UNIX

Ans. Used for-creation of more than one file

32.In UNIX .profile contains

Ans. Start up program

33.In UNIX echo is used for

( answer C)

34.In UNIX 'ls 'stores contents in

Ans.inode block QUANTITATIVE SECTION

1. In a class composed of x girls and y boys what part of the class is composed of girls A.y/(x + y) B.x/xy C.x/(x + y) D.y/xy [Ans.C ]

2.What is the maximum number of half-pint bottles of cream that can be filled with a 4-gallon can of cream(2 pt.=1 qt. and 4 qt.=1 gal) A.16 B.24 C.30 D.64 [Ans.D ]

3. If the operation,^ is defined by the equation x ^ y = 2x + y,what is the value of a in 2 ^ a = a ^ 3 A.0 B.1 C.-1 D.4 [Ans.B ]

4. A coffee shop blends 2 kinds of coffee,putting in 2 parts of a 33p. a gm. grade to 1 part of a 24p. a gm. If the mixture is changed to 1 part of the 33p. a gm. to 2 parts of the less expensive grade,how much will the shop save in blending 100 grams. A.Rs.90 B.Rs.1.00 C.Rs.3.00 D.Rs.8.00 [Ans.C ]

5. There are 200 questions on a 3 hr examination. Among these questions are 50 mathematics problems. It is suggested that twice as much time be spent on each maths problem as for each other question. How many minutes should be spent on mathematics problems A.36 B.72 C.60 D.100

Ans.B

6. In a group of 15,7 have studied Latin, 8 have studied Greek, and 3 have not studied either. How many of these studied both Latin and Greek A.0 B.3 C.4 D.5

Ans.B

7. If 13 = 13w/(1-w) ,then (2w)2 = A. 1/4 B. 1/2 C. 1 D. 2 [Ans.C ]

8. If a and b are positive integers and (a-b)/3.5 = 4/7, then (A) b < a (B) b > a

(C) b = a (D) b >= a [Ans. A]

9. In June a baseball team that played 60 games had won 30% of its game played. After a phenomenal winning streak this team raised its average to 50% .How many games must the team have won in a row to attain this average? A. 12 B. 20 C. 24 D. 30 [Ans. C]

10. M men agree to purchase a gift for Rs. D. If three men drop out how much more will each have to contribute towards the purchase of the gift.

A. D/(M-3) B. MD/3 C. M/(D-3) D. 3D/(M2-3M) [Ans. D]

11. A company contracts to paint 3 houses. Mr.Brown can paint a house in 6 days while Mr.Black would take 8 days and Mr.Blue 12 days. After 8 days Mr.Brown goes on vacation and Mr. Black begins to work for a period of 6 days. How many days will it take Mr.Blue to complete the contract? A. 7 B. 8 C. 11 D. 12 [Ans.C]

 12. 2 hours after a freight train leaves Delhi a passenger train leaves the same station travelling in the same direction at an average speed of 16 km/hr. After traveling 4 hrs the passenger train overtakes the freight train. The average speed of the freight train was?

A. 30 B. 40 C.58 D. 60 [Ans. B]

 13. If 9x-3y=12 and 3x-5y=7 then 6x-2y = ? A.-5 B. 4 C. 2 D. 8 [Ans. D]