ExpertKelish Rai
Technical Content Writer @Programiz
Answered 89 questions
About
Hi, I'm Kelish, Technical Content Writer at Programiz. I break down complex programming concepts and turn them into easy-to-understand articles, tutorials, and courses. I'm also a developer at heart—I love solving coding problems, exploring algorithms, and staying updated with the latest tech stuff. If I'm not writing content, there's a good chance I'm working on a side project.

When working on a real project, you might organize your files in a structured way using folders inside other folders. This is what we mean by a nested directory structure.
For example:
website
│── home
│ │── index.html
│ │── images
│ │ │── banner.png Here, banner.png is inside the images folder, which is inside the home folder, making it a nested directory structure.
Since index.html is in the home folder, you’d reference the image like this:

This tells the browser to look inside the images folder, which is in the same directory as index.html, to find banner.png.

When working on a real project, you might organize your files like this:
website
│── home
│ │── index.html
│ │── banner.pngHere, website is the root folder, and it contains another folder called home. Inside home, both index.html and banner.png are stored in the same location.
When we say "the image is in the same directory as the HTML file", we mean that both files exist within the same folder.
Now, inside index.html, you can easily reference banner.png like this:

This tells the browser to look for banner.png in the same folder as index.html.

DSA (Data Structures and Algorithms) is all about solving problems efficiently using the right tools.
Data structures help organize and store data—like arrays, lists, stacks, queues, trees, and graphs.
Algorithms are step-by-step instructions to perform tasks like searching, sorting, or finding the shortest path.
Real-Life Examples of DSA in Action:
Search engines use efficient algorithms to return results in milliseconds.
Social media platforms use graph algorithms to suggest friends and show relevant content.
GPS apps use shortest path algorithms (like Dijkstra’s) to find the fastest routes.
E-commerce websites use sorting and recommendation algorithms to show you useful product suggestions.
In short, DSA makes software faster, smarter, and more responsive. It’s not just for interviews or school—it’s what helps technology scale and perform in the real world.
Learning DSA also builds strong problem-solving skills and helps you understand how systems work under the hood.
You can also check out our blog Data Structures and Algorithms in Everyday Life to learn more on this.

No, you don't need always quotation marks when creating variables. For example,
age = 25In this case, age is a variable that stores the value 25. Since 25 is a number, we don't need to use quotation marks around it.
However, if you're storing a string in a variable, you must enclose the value with quotation marks. For example,
favorite_food = "Pizza"Here, favorite_food is a variable, storing the string "Pizza".
As for spaces around the equal sign, Python doesn’t require them, but adding spaces makes the code easier to read:
age=25
age = 25Here, age=25 works but age = 25 is cleaner and easier to understand.

In C, you can take user input using the scanf() function. It reads values entered by the user and stores them in variables. For example,
#include
int main() {
int number;
printf("Enter a number: ");
// Take input and store it in number variable
scanf("%d", &number);
printf("You entered: %d\n", number);
return 0;
} Output
Enter a number: 42
You entered: 42Here,
printf()asks the user to enter a number.scanf("%d", &number);takes the user's input and stores it in thenumbervariable.%dtellsscanfthat you're expecting an integer.&numberis the address of the variable where the input will be stored.
Finally,
printf()displays the entered number.
Note: Always remember to use & (address-of operator) before the variable name in scanf().

In C++, the return 0; statement simply indicates that the program has completed successfully. It tells the system that the program ran without errors.
For example:
#include
using namespace std;
int main() {
cout << "Hello, world!" << endl;
return 0;
} In the code:
The program prints
"Hello, world!".The
return 0;line sends a status code back to the system—0traditionally means success.If something went wrong in your program and you wanted to signal that to the system, you could return a non-zero value like
return 1;.
Why does this matter?
If you're running your program in a larger system or calling it from a script, the return value lets that system know whether the program succeeded. This is useful in automated testing, system monitoring, or when chaining commands in shell scripts.
So while it may seem small, return 0; plays an important role in communicating the outcome of your program to the system.

Yes, you can use f-strings outside of print().
An f-string is just a formatted string, meaning you can use it anywhere a string is used.
Example 1: Assigning to a variable:
name = "Alice"
message = f"Hello, {name}"
print(message) # Output: Hello, AliceExample 2: Writing to a file:
age = 30
with open("info.txt", "w") as file:
file.write(f"User age: {age}")Example 3: Passing as a function argument:
def greet(msg):
print(msg)
greet(f"Welcome back, {name}!")In all of these examples, the f-string is being used to build a string dynamically with variables or expressions, then used just like any regular string—stored, written, passed, or returned.
F-strings are one of the most efficient and readable ways to format strings in Python, and you'll keep finding more ways to use them as your projects grow.

The main difference between function overloading and function overriding in C++ comes down to where and how the functions are defined.
1. Function overloading
Happens in the same class
Functions have the same name but different parameters (different number or types)
The compiler decides which function to call based on the arguments
Example:
#include
using namespace std;
class Animal {
public:
// Function with no parameters
void make_sound() {
cout << "Animal Sound" << endl;
}
// Overloaded function with an integer parameter
void make_sound(int count) {
cout << "Animal Sound (" << count << ") times" << endl;
}
};
int main() {
Animal a1;
// Calls the function without parameters
a1.make_sound(); // Output: Animal Sound
// Calls the overloaded function with an integer argument
a1.make_sound(10); // Output: Animal Sound (10 times)
return 0;
} Here, calling make_sound() and make_sound(10) will call different versions of the function.
2. Function overriding
Happens between a base class and a derived class
Functions have the same name and parameters
The derived class function replaces the base class function when called via an object of the derived class
Example:
#include
using namespace std;
class Animal {
public:
// Function to make a generic animal sound
void make_sound() {
cout << "Animal Sound" << endl;
}
};
class Dog: public Animal {
public:
// Overrides the Animal class' make_sound() function
void make_sound() {
cout << "Woof Woof" << endl;
}
};
int main() {
// Create object of the child (Dog) class
Dog dog1;
// Calls the overridden function in child (Dog) class
// and not base (Animal) class
dog1.make_sound();
return 0;
}
// Output: Woof Woof Here, calling make_sound() on the Dog class executes the function of the Dog class, overriding the make_sound() function of the Animal class.
Also, one thing to note is just because function overloading happens within the same class doesn't mean it can't be used alongside inheritance.
You can still overload functions in a base class and its derived class, as long as the overloaded functions follow the usual rules—having the same name but different parameter lists.


The use of %d and %d% is related to the LIKE operator, which is used to search for a specified pattern in a column. The % character is a wildcard that can represent any sequence of characters (including no characters at all). Here's how they work:
%d: This pattern is used to find values that end with the letter 'd'. For example,
SELECT * FROM table WHERE column LIKE '%d';This will return all rows where the column ends with the letter 'd'. For example, it would match "keyboard", "mousepad", and "sand".
%d%: This pattern is used to find values that contain the letter 'd' anywhere in the string. For example,
SELECT * FROM table WHERE column LIKE '%d%';This will return all rows where the column contains the letter 'd' at any position in the string. For example, it would match "ride", "window", and "card".

In Python, lists and dictionaries are two important data types that allow you to store and organize data in different ways.
A list is an ordered collection of items where each item is identified by an index (starting from 0). Lists are created using square brackets []. For example,
fruits = ["apple", "banana", "cherry"]
print(fruits[0]) # Output: appleA dictionary is a collection of key-value pairs where each value is accessed by its unique key, not by index. Dictionaries are created using curly braces {}. For example,
person = {"name": "Alice", "age": 25}
print(person["name"]) # Output: AliceBoth are very flexible and widely used for different purposes in Python programming.