-
Diffenentiate between an internal static and external static variable?
An internal static variable is declared inside a block with static storage class whereas an external static variable is declared outside all the blocks in a file.An internal static variable has persistent storage,block scope and no linkage.An external static variable has permanent storage,file scope and internal linkage.
-
What are advantages and disadvantages of external storage class?
Advantages of external storage class1)Persistent storage of a variable retains the latest value2)The value is globally available Disadvantages of external storage class1)The storage for an external variable exists even when the variable is not needed2)The side effect may produce surprising output3)Modification of the program is difficult4)Generality of a program is affected
-
-
When does the compiler not implicitly generate the address of the first element of an array?
Whenever an array name appears in an expression such asØ array as an operand of the sizeof operatorØ array as an operand of & operatorØ array as a string literal initializer for a character arrayThen the compiler does not implicitly generate the address of the address of the first element of an array
-
What is modular programming?
If a program is large, it is subdivided into a number of smaller programs that are called modules or subprograms. If a complex problem is solved using more modules, this approach is known as modular programming.
-
What are the advantages of the functions?
Ø Debugging is easierØ It is easier to understand the logic involved in the programØ Testing is easierØ Recursive call is possibleØ Irrelevant details in the user point of view are hidden in functionsØ Functions are helpful...
-
Point out error, if any, in the following program main() { int i=1; switch(i) { case 1: printf("nRadioactive cats have 18 half-lives"); break; case 1*2+4: printf("nBottle for rent -inquire within"); break; } }
No error. Constant expression like 1*2+4 are acceptable in cases of a switch.
-
-
Point out the error in the following program
main()
{
const char *fun();
*fun()='A';
}
const char *fun()
{
return "Hello";
}
fun() returns to a "const char" pointer which cannot be modified
-
Loops in C programming.
main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j -
Recursion C program.
main() { static int var = 5; printf("%d ",var--); if(var) main(); }
Ans:5 4 3 2 1 Explanation:When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively. -
Different ways of expressing the same idea.
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]);}
Ans: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... -
Program listing IP addresses of all active clients.
Write a program which sends a token on network and give the list of IP addresses of all the client currently active ?(program is running on server)
-
Matrix Manipulation library in C
Let's say you want to develop a Matrix manipulation library in pure C (not C++). For example, you want to define a "matrix_multiply" function to get A * B, how to declare the function and how to implement it? Make sure that you consider error handling stuff, e.g., a 2*2 matrix and a 3*3 matrix cannot multiply, and how to detect and deal with the situation when you pass a 3*3 matrix as a parameter which...
-
Overload subscript operator
How will you Overload subscript operator with more than one dimension?
-
-
How can I do this using recursion ?
For the List class, add a Boolean-valued function that determines whether the data items in the linked list are arranged in ascending order. How can I do this using recursion ?
-
-
-
C Interview Questions
Ans