-
-
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...
-
-
-
Find the factorial of given positive integer.
Consider the following code for finding the factorial of given positive integer IFACT=1 DO 100 I=2,N,2 100 IFACT = IFACT*i*(i-1) For which value of N, the above FORTRAN code will not work ? 1. N is even 2. N is odd 3. N is perfect number 4. N mod 3 =0
-
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
-
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... -
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. -
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 -
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