Skip to content

Category Archives: Programming Language

scanf family functions support scanset specifiers which are represented by %[]. Inside scanset, we can specify single character or range of characters. While processing scanset,… Read More
The C99 standard allows variable sized arrays (see this). But, unlike the normal arrays, variable sized arrays cannot be initialized. For example, the following program… Read More
Most of the times declarations are simple to read, but it is hard to read some declarations which involve pointer to functions. For example, consider… Read More
Scope of an identifier is the part of the program where the identifier may directly be accessible. In C, all identifiers are lexically(or statically) scoped.… Read More
Consider the following C programs. // PROGRAM 1 #include<stdio.h>    int main(void) {     int a = 1, 2, 3;     printf("%d", a);     return 0; } The… Read More
Predict the output of following C++ program. C++ #include <iostream> using namespace std;   int main() {     try     {         throw 'x';     }     catch(int x)     {… Read More
Question: How to deallocate dynamically allocate memory without using “free()” function. Solution: Standard library function realloc() can be used to deallocate previously allocated memory. Below… Read More
Predict the output of following C++ program. #include <iostream> using namespace std;    class Test { public:   Test() { cout << "Constructing an object of… Read More
A function is called pure function if it always returns the same result for same argument values and it has no side effects like modifying… Read More
Ever wondered how can you design a class in C++ which can’t be inherited. Java and C# programming languages have this feature built-in. You can… Read More
The volatile keyword is intended to prevent the compiler from applying any optimizations on objects that can change in ways that cannot be determined by… Read More
Consider the following Java program: class Complex {     private double re, im;                public Complex(double re, double im) {         this.re = re;         this.im = im;… Read More
Prerequisite – Constructors in Java Like C++, Java also supports copy constructor. But, unlike C++, Java doesn’t create a default copy constructor if you don’t… Read More
Predict the output of following C++ program. #include <iostream> using namespace std;    template<int n> struct funStruct {     enum { val = 2*funStruct<n-1>::val }; };… Read More
The purpose of inheritance is same in C++ and Java. Inheritance is used in both languages for reusing code and/or creating an ‘is-a’ relationship. The… Read More