Professional Documents
Culture Documents
while(1)
{
}
2. Difference between macro and inline functions?
macro is preprocessing directive. Debugging is difficult. we can debug inline functions. Inline functions substitute
the code at calling fun only. Inline functions are faster compared to macro. Inline occupies more memory
compared to Macro, because when ever inline function called entire code is pasted to the caller.
3. What is constant function explain with program? can constant functions can access all data members in class?
class base
{private:
int a;
public;
func () constant;
}
constant function can access all the data members .but, constant data members can be accessed by constant
member functions only
4. Write a program to copy a string that will return a pointer to the starting location?
Strcopy (char*t, char*s)
{
while(* t!='\0')
*t=*s;
s++;
t++;
}
*t='\0';
return(t[0]);
}
5. Write a program for memory allocation for 100 bytes of data?
int*a=(int*)malloc(100*size of (int);
6. WAP for memory allocation of two-dimensional array of size 10*10? ( char **ptr) ???
7. Write a program which takes integer inputs and calls the functions
accordingly?
Input - function
10
- func A
40
- func B
70
- func C
120
- func D]
main()
{
int n;
pritnf("\n enter any interger value");
scanf("%d",&n)
switch(n)
case10:funca();
break;
case40:funcb();
break;
case70:funcc();
break;
case120:funcd();
break;
}
8. Write a program for single linked list- creation, insertion, deletion and reverse
9. Derived*ptr = new base;
No this is not valid. Pointer is derived type and we cannot allocate memory of base type.
10. What are files? How the files concept useful in C? Have u worked with files?
In c programs will be stored in different files. And we can include on file into other file when we want to use. Using
files concept we can spilt our program instead of one big program.
11. What are enumeration constants? Are they can be modified? Have used in programming? How r they useful?
Using enumerated data types we can assign question own data types. Each value on the list of permissible values
corresponds to an integer starting with zero.
We can modify them.
These are used to clarify the program.
13. Write a program to convert decimal numbers to binary numbers in one line?
By and ing that decimal number with 01.
14. What is difference between definition and declaration?
Declaration will not store any place. Definition will allocate memory.
15. Questions on complicated declarations? Pointers and functions
Char (*(*x [3]) ( )) [5];
x is an array of 3 integer pointers of a function returning a pointer to an array of 5 characters.
16. What is ifdef and elif? do u know these? what is significance of these?
ifdef is used check whether a partcular macro is defined or not.
elif is test whether an _expression evaluates to zero or not.
these are preprocessive directives.
C LANGUAGE:
1. When doubly linked list is useful and when is singly linked list is useful?
2. When singly linked list is useful and when is array is useful?
For insertion, deletion, memory allocation during running time linked list is useful. For fast accessing arrays are
useful
3. What is difference between structure and union?
Structure allocate continues memory for all the declared variables, whereas union allocate single copy of
memory .
4. What is size of the union if it has three variables one int, one char and one double?
4 bytes( size of double)
5. What do u about static variable?
If we declared a variable as static variable then it can visible to other functions and its value persists between
different function calls.
6. If static variable declared out side the main program then how it will work?
Then it cannot be accessible to other files.
7. How the extern keyword is useful?
By declaring a variable using extern keyword then we access the global variable declared in other files
8. If I declared as Extern int x=1; will it get compiled? How? What r errors? How they occurred?
It will be syntax error as redeclaration of x
9. How will write code for 2s compliment of a binary number?
Using ~(tilt) we can get 1s compliment by adding one to that number we can get 2s compliment
10. I declared a variable as signed int? how will u check whether it is signed or unsigned?
By checking it boundaries. Means signed integer can have highest value upto32767 for 16 bit machine.
11. If the size of the integer is 2 bytes. What is the maximum size that signed variable can have?
32767
12. How can u access a variable which is in another file?
Using extern keyword
13. How will u include a header file in your code?
Using #include
14. If I declared a variable in header1.h file and it included in header2.h and header 3.h. And all these three are
included in file1.c then how it will get executed?
No it will not execute. We get syntax error as redeclaration of the variable. We can overcome this using IFDEF.
15. What r different stages that a file go in compilation?
Compiler, linker, loader
C questions:
What
Global variable can be accessed from other functions. Static variables cannot be accessed. Both store the
values in the memory till the end of the program.
what is difference between the variables declared as static and global outside main function?
If we declared two variables inside a function one as static and other as global? What is the difference between
these two?
Both will act like same
What happens if we declared a register variable to store 100 bytes of data? Will it save? If not what happens to
the variables?
But the no. of registers is very less so the compiler will decide whether to store in registers or not depending
upon the requirement of registers,. If reg are not free it will store them as automatic variables.
How does a union save two integers? How memory allocated to these two variables?
Union will allocate memory for largest data type.
If I declared two variables one is an array of 10 integers and other is integer pointer which has allocated a
memory of 10 integers. Then what is the difference of these two?
Both are same. Using pointers is safe.
How do u find whether the given number is integer or not without using modulus operator?
What
is size of a pointer? What is size of integer pointer in 16 bit machine and 32 bit machine? What is size of
character pointer for 16 and 32bit machine?
Size of integer 2 and char is 1 in 16 bit machine. In 32 bit machine int is 4 and char is 2
Microcontroller:
How many input ports are there in a micro cont roller? How many output ports are there?
Microcontroller has 40 pins all can be used as input and output ports
Questions asked:
1)
2)
3)
4)
5)
6)
7)
8)
9)
(b) int *f (char k);- function taking a character variable as an argument and returning a
integer pointer
19) Dynamic memory management in C++
20) How can you delete the memory allocated for
Char *p = new char [100];
Delete p;
21) Draw the use case diagram for your project done.
22) Write a class with two members in it.
23) Are you perfect in Oracle
24) How long did u work on UNIX.
25) For the code below--Void f(int a)
{
Int b=a;
Cout <<b << end;
}
If f is function, what is the lifetime of the variable b
Upto this function only.
----------------------------------------------------------------------------------------------------------------------C++, UNIX, wipro 2+yrs
1) Tell me about Ur self?
2) Tell me about the ospf project?
3) Is it a connection oriented or connection less?
Connection oriented
4) What are client and server side system calls for connection oriented?
Client
server
Socket()
socket()
Bind()
Listen()
Connect()
accept()
Write()
read()
Read()
write()
Close()
close()
5) What are client and server side system calls for connection less?
Client
server
Socket ()
socket ()
Bind ()
bind ()
Send to ()
recvfrom ()
Recvfrom () sendto ()
Close ()
close ()
6) What are the arguments for listen system call?
Listen (socket id, no. of clients)
7) What does bind system call do?
The bind system call associates a name with the socket descriptor. Server processes bind
addresses to socket and advertise their names to identify themselves to client processes.
8) What is the return type of socket system call?
Socket descriptor
9) What is router?
Router is used to connect two or more no .of networks
}
Ans The only operations that can be performed directly on an array value are the application of
the sizeof and address (&) operators. For sizeof, the array must be bounded and the result is the
number of storage units occupied by the array. The result of & is a pointer to (the first element of)
the array. And, in the above program we are trying to increment array type, b, which is not allowed.
It is an error.