Two elements of complex data types are not directly comparable. Consider the student structure defined as below struct Student { int rollNo; char name[25]; char grade; }; Student arr[MAX_NUM_STUDENTS]; Objects of Student type are not directly comparable. To sort array arr, we need to specify how one student compares with another student. If there are […]
What improvement has java-8 made that performance of HashMap.get() function call is fast by 20% in Java-8.
Generic programming, loosely means that the code we have written is type-independent. It is a larger topic, macros in C language also comes under generic programming. In this post we are only discussing generic pointers.
How will you find minimum of three integers without using any comparison operator ?
Write a class which will implement the Stack data structure in C++. Give the declaration & definition of the class. Also define the Node. For simplicity, you may assume stack to hold integer data type.
The below C++ code will print “Hello World”. #include <iostream> int main() { cout<<“Hello World”; } Without modifying main function, add code to print “Ritambhara” before “Hello World”. You cannot add/remove any statement to main function
Write a C language function that will swap two strings.
What will be the output of the below C++ program: // Template Function – Not taking class template <class T, int i> int myFun(){ T x = 10; i = 20; } int main(){ fun<int, 4>(); return 0; }
While comparing a variable with a constant (literal) in C/C++ language, which of the two ways of comparison should we use ? if( x == 2 ) … if( ptr == NULL ) … Or if( 2 == x ) … if( NULL == ptr ) … In the first comparison we are writing variable […]
Object of a class can be created dynamically on heap or statically on Stack or Data Area. If we have a class MyClass, then the below objects will be created on heap. // Operator: New MyClass *ptr1 = new MyClass(); // Crating object of MyClass on heap. // Operator: New-Array MyClass *ptr2 = new MyClass[10]; // […]