-
Importance of Algorithms
What is the importance of algorithms in the field of computer science?
-
Error Code
Will this code cause an error during runtime, error during compilation, or no error? 1.) char str[5]; strcpy (str, "hello"); 2.) char *str; strcpy (str, "hello");
-
Find Number of Occurrences
How will you find the number of occurrences of a particular string in the given input string?
-
Sequence of Function Execution
printf("%d%d",f1(),f2());What is the sequence of function execution of the above statement. 1. printf, f1(), f2()2. printf, f2(), f1()3. f1(), f2(), printf4. f2(), f1(), printf.
-
Recursion
What is recursion? Which data structure is used for recursion
-
Pointer to Unsingned int
Why it is not possible to create pointer to unsingned int?
-
Garbage Value
In C if a variable is not assigned a value then why does it take garbage value?
-
Maximum combined length of command line arguments in C
What is the maximum length of command line arguments including space between adjacent arguments ?
-
Memory Stack or Heap
which type of memory(stack or heap)is used by static and external variables?
-
fflush() in Multiple Scanf calls
What is the requirment of using fflush() in multiple scanf calls.
-
A Program that does nothing
Write a program in C that does nothing not even takes memory?
-
Field Width Specification
What is Field Width Specification?
-
What will be difference b/w 5th and 6th statements?
1. #define MAX 1002. main()3. {4. int max=100;5. int a[MAX];6. int b[max];7. }
-
Memory Allocation
we say stack is allocated to the local variables ,formal arguments and return addresses of a function for manipulating function calls?but the question arises when does the stack allocation to above things take place?at compile time or run time.And by the way what about automatic memory allocation.what is it?
-
-
Difference between reference and pointer?
what is difference between reference and pointer or pass by reference and pass by pointer?
-
What's the best way to declare and define global variables
What's the best way to declare and define global variables and functions?
-
-
Find the binary form
Write a program to find the binary form for the given charcter input.eg:- for 'A' ASCII value is 65 and its binary form is 1000001.
-
-
-
-
What is the difference between structure & union?
how can we multiply this A*B without using "*" operator?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
strcat(buf,buf);
printf(buf);
}
While executing this in VC++ I do not get an output . Looks like the program runs into an infinite loop. But while executing the same in Turbo C I get the output as "hellohelloh". What could be the reason behind this difference in output?">Consider the following program segment :#include #include void main () { char buf[100] = "hello"; strcat(buf,buf); printf(buf);}While executing this in VC++ I do not get an output . Looks like the program runs into an infinite loop. But while executing the same in Turbo C I get the output as "hellohelloh". What could be the reason behind this difference in output?
-
-
-
According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
A) main(int argc, char *argv[]) B) main(argc,argv) int argc; char *argv[];C) main() {int argc; char *argv[]; }D) None of the above
-
-
-
-
-
why n++ executes faster than n+1?
The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas, n+1 requires more instructions to carry out this operation.
-
Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?
It’s easier for a C compiler to generate good code for pointers than for subscripts.
-
Is NULL always defined as 0?
NULL is defined as either 0 or (void*)0. These values are almost identical; either a literal zero or a void pointer is converted automatically to any kind of pointer, as necessary, whenever a pointer is needed (although the compiler can’t always tell when a pointer is needed).
-
How can I convert a number to a string?
The standard C library provides several functions for converting numbers of all formats (integers, longs, floats, and so on) to strings and vice versa The following functions can be used to convert integers to strings: Function Name Purpose itoa() Converts an integer value to a string. ltoa() Converts a long integer value to a string. ultoa() Converts an unsigned long integer value to a string....
-
How are portions of a program disabled in demo versions?
If you are distributing a demo version of your program, the preprocessor can be used to enable or disable portions of your program. The following portion of code shows how this task is accomplished, using the preprocessor directives #if and #endif: int save_document(char* doc_name) { #if DEMO_VERSION printf(“Sorry! You can’t save documents using the DEMO version of this program!n”); return(0); #endif...
-
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 not several instances of individual constants throughout your program. For instance, if your program used the value of pi (approximately 3.14159) several...
-
What is the difference between text and binary modes?
Streams can be classified into two types: text streams and binary streams. Text streams are interpreted, with a maximum length of 255 characters. With text streams, carriage return/line feed combinations are translated to the newline n character and vice versa. Binary streams are uninterpreted and are treated one byte at a time with no translation of characters. Typically, a text stream would be used...
-
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 essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all...
-
When should a type cast not be used?
A type cast should not be used to override a const or volatile declaration. Overriding these type modifiers can cause the program to fail to run correctly. A type cast should not be used to turn a pointer to one type of structure or data type into another. In the rare events in which this action is beneficial, using a union to hold the values makes the programmer’s intentions clearer.
-
When should a type cast be used?
There are two situations in which to use a type cast. The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly. The second case is to cast pointer types to and from void * in order to interface with functions that expect or return void pointers. For example, the following line type casts the return value of the call to malloc()...
-
How can you determine the maximum value that a numeric variable can hold?
For integral types, on a machine that uses two’s complement arithmetic (which is just about any machine you’re likely to use), a signed type can hold numbers from –2(number of bits – 1) to +2(number of bits – 1) – 1. An unsigned type can hold values from 0 to +2(number of bits) – 1. For instance, a 16-bit signed integer can hold numbers from –2^15 (–32768) to +2^15 – 1 (32767).