< 1 2 3 4 5 6 7 > >>   Sort: Date

What does static variable mean
What does static variable mean? There are 3 main uses for static variables: If you declare within a function, it retains the value between function calls. If it is declared for a function name, by default function is extern. So it will be visible from other files. If the function declaration is as s...
2007-02-26, 6768👍, 0💬

Including Source Files
What is the result of using Option Explicit? When writing your C program, you can include files in two ways. The first way is to surround the file you want to include with the angled brackets &lt; and &gt;. This method of inclusion tells the preprocessor to look for the file in the predefine...
2007-02-26, 6756👍, 0💬

Modulation Operations
Write an equivalent expression for x%8? x&amp;7
2007-02-26, 6745👍, 0💬

Constants
WHat will be the result of the following code? #define TRUE 0 // some code while (TRUE) { // some code } Answer: This will not go into the loop as TRUE is defined as 0.
2007-02-26, 6724👍, 0💬

Storage Classes
What are the different storage classes in C? C has three types of storage: automatic, static and allocated. Variable having block scope and without static specifier have automatic storage duration. Variables with block scope, and with static specifier have static scope. Global variables (i.e, file s...
2007-02-26, 6700👍, 0💬

Using Macros for Contants
What is the benefit of using #define to declare a constant? Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to maintain only the #define statement and...
2007-02-26, 6677👍, 0💬

malloc Function
Why does malloc(0) return valid memory address? What's the use? malloc(0) does not return a non-NULL under every implementation. An implementation is free to behave in a manner it finds suitable, if the allocation size requested is zero. The implmentation may choose any of the following actions: * A...
2007-02-26, 6652👍, 0💬

Searching Date in Linked Lists
How can I search for data in a linked list? Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list's members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structur...
2007-02-26, 6612👍, 0💬

How can I implement a variable field width with printf?
How can I implement a variable field width with printf? That is, instead of something like %8d, I want the width to be specified at run time. printf("%*d", width, x) will do just what you want. The asterisk in the format specifier indicates that an int value from the argument list will be used for t...
2021-01-21, 6611👍, 1💬

💬 2021-01-21 John Doe: Hello

What Is Hashing
What is hashing? To hash means to grind up, and that's essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer. The idea behind hashing is that some data either has no inherent ordering ...
2007-02-26, 6607👍, 0💬

Incremental Operatiors
What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf("%d %d\n",x,y); } Answer: 11, 16
2007-02-26, 6588👍, 0💬

Incremental Operatos
What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf("%d%d\n",x,y); } Answer : 5794
2007-02-26, 6575👍, 0💬

Nesting Include Files
Can include files be nested? The answer is yes. Include files can be nested any number of times. As long as you use precautionary measures , you can avoid including the same file twice. In the past, nesting header files was seen as bad programming practice, because it complicates the dependency trac...
2007-02-26, 6573👍, 0💬

"volatile" Modifier
when should the volatile modifier be used? The volatile modifier is a directive to the compiler's optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-...
2007-02-26, 6545👍, 0💬

What is page thrashing
What is page thrashing? Some operating systems (such as UNIX or Windows in enhanced mode) use virtual memory. Virtual memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate RAM (random-access memory). In the 80386 and higher Int...
2007-02-26, 6542👍, 0💬

Function Calls
What will be printed as the resultof the operation below: int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyva...
2007-02-26, 6532👍, 0💬

Function Calls
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a, int b) { int temp; temp=a; b=a; a=temp; return 0; } The correct answer is 10, 5 5, 10
2007-02-26, 6530👍, 0💬

What Is the Quickest Sorting Method?
What is the quickest sorting method to use? The answer depends on what you mean by quickest. For most sorting problems, it just doesn't matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the...
2007-02-26, 6515👍, 0💬

Conditional Statements
What will be printed as the result of the operation below: main() { int a=0; if (a==0) printf("Cisco Systems\n"); printf("Cisco Systems\n"); } Answer: Two lines with "Cisco Systems" will be printed.
2007-02-26, 6500👍, 0💬

Strings vs. Character Arrays
What is the difference between strings and character arrays? A major difference is: string will have static storage duration, whereas as a character array will not, unless it is explicity specified by using the static keyword. Actually, a string is a character array with following properties: * the ...
2007-02-26, 6489👍, 0💬

Using Pointers
What print out will the folloging code produce? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(“%s\n”,p2);> } The pointer p2 value is also increasing with p1 . *p2++ = *p1++ means copy value of *p1 to *p2 , then increment both addresses (p...
2007-02-26, 6486👍, 0💬

Pointer to Constants
What is the difference between const char* p and char const* p? In const char* p, the character pointed by "p" is constant, so you can not change the value of character pointed by p but u can make "p" refer to some other location. In char const* p, the pointer "p" is constant not the character refer...
2007-02-26, 6455👍, 0💬

Overriding Defined Macros
How do you override a defined macro? You can use the #undef preprocessor directive to undefine (override) a previously defined macro.
2007-02-26, 6433👍, 0💬

Conditional Statements
What will happen in these three cases? if (a=0) { //somecode } if (a==0) { //do something } if (a===0) { //do something }
2007-02-26, 6381👍, 0💬

< 1 2 3 4 5 6 7 > >>   Sort: Date