Ask Programiz - Human Support for Coding Beginners
Explore questions from fellow beginners answered by our human experts. Have some doubts about coding fundamentals? Enroll in our course and get personalized help right within your lessons.

The reason we create variables is to store values in a way that makes our code easier to manage and update.
Take this example:
print("Hi everyone!")
print("Hi everyone!")
print("Hi everyone!")
print("Hi everyone!")Now, suppose you want to greet your friend instead, say Alice. You’d have to manually change every line:
print("Hi Alice!")
print("Hi Alice!")
print("Hi Alice!")
print("Hi Alice!")That can get repetitive and time-consuming, especially as your program grows. But if you use a variable, things get much simpler:
greeting = "Hi everyone!"
print(greeting)
print(greeting)
print(greeting)
print(greeting)
print(greeting)Now, to greet Alice, you only need to change the value in one place:
greeting = "Hi Alice!"
print(greeting)
print(greeting)
print(greeting)
print(greeting)
print(greeting)As you can see, variables help save time and make your code more flexible. And when you're working with more data or writing bigger programs, they become even more useful.

Yes, you can technically use void main() instead of int main(). However, it's not recommended.
According to the C++ standard, the correct and portable way to define the main function is:
int main() {
// your code here
return 0;
}This version is universally accepted and ensures that your program can properly communicate with the operating system. The return 0; statement signals that the program finished successfully.
If you use void main(), you won't be able to use return 0; because the function doesn’t return anything. That might not cause an error in some compilers, but it's considered non-standard and could lead to unpredictable behavior or reduced portability.
In short:
Use
int main()for standard, portable, and reliable C++ code.void main()might work in some environments, but it’s not guaranteed.

Data types in most programming languages follow a similar concept, and Java and Python are no exception. However, there is an important distinction to understand between the two.
Java is a statically typed language, meaning that when you declare a variable, you must specify its data type upfront (like int, String, etc.). This can make your code more structured, but it also requires you to be more specific.
int age = 25;
String name = "Alice";On the other hand, Python is dynamically typed. You don't need to declare a variable's type explicitly — Python figures it out for you based on the value assigned to the variable. This makes Python a bit more flexible and easier for beginners to start with.
age = 25
name = "Alice"Even though the concept of data types (like numbers, strings, booleans) is present in both Java and Python, the way they're handled is different because of static vs dynamic typing.

In JavaScript, variable names cannot start with a number. They need to begin with a letter, an underscore (_), or a dollar sign ($). However, you can use numbers in the middle or at the end of the variable name.
For example, these are valid variable names:
myVariable1variable_2$_value
But these are not valid:
1stVariable123name
Note: If you try to start a variable name with a number, JavaScript will throw a syntax error when you run the code.

A programmer is someone who writes code to instruct computers on how to perform tasks. It’s a bit like giving a computer a set of instructions in a language it understands, so it can run apps, websites, games, or even control hardware.
Programmers use various programming languages to communicate with computers. These languages are designed in a way that allows the computer to "read" and follow the instructions.
C is one of these languages, and it’s well-known for its efficiency and speed, which is why it's been used for so long, especially in system-level programming.
Consider a simple program like this:
#include
int main() {
printf("Hello, world!");
return 0;
} This program simply tells the computer to print "Hello, world!" to the screen. The programmer writes the instructions in C, and the computer executes them.

The difference between a compiler and an interpreter mostly comes down to how they translate our code into machine-understandable language:
A compiler converts the entire code at once, creating a separate file (like an executable) that can be run later. Once compiled, you don’t need the source code to run the program.
An interpreter, on the other hand, translates the code line by line as it runs the program. It doesn’t produce an executable file; instead, it processes the code directly during execution.
This difference affects several aspects of how the code is executed, like execution speed and error handling.
Here's an example to make the difference clearer:
1. Compiled language (e.g. C):
// hello.c
#include
int main() {
printf("Hello, world!\n");
return 0;
} You would first compile this using a compiler like gcc:
gcc hello.c -o helloThen run the compiled file:
./hello2. Interpreted language (like Python):
# hello.py
print("Hello, world!")You just run it directly with the Python interpreter:
python hello.pyNote: Some modern languages use both techniques. For example, Java code is compiled into bytecode, which is then interpreted (or further compiled) by the Java Virtual Machine (JVM).

That’s completely okay—positions in CSS can feel a bit tricky at first. The best way to get the hang of them is to experiment with different values in your code and observe how the output changes.
Now, let’s break down position: relative in a simple way.
When you apply position: relative to an element, it allows you to move that element relative to where it would have naturally appeared on the page. It doesn’t take the element out of the normal flow—it just lets you shift it a bit.
For example, imagine we have a div with this basic style:
.box {
width: 100px;
height: 100px;
background: red;
}Without any positioning, the browser places it in its default spot in the flow of the page.
Let's say you want to move this box 20px lower from where it currently is. You can do that like this:
.box {
position: relative;
top: 20px;
width: 100px;
height: 100px;
background: red;
}With position: relative and top: 20px, the box visually shifts down by 20px from its original location—but its original space is still preserved. That means other elements around it won’t move into the gap where it used to be.
You can also use left, right, or bottom in the same way to shift the element in other directions.

When you're first learning to code, it's a common tradition to start by displaying Hello, World!—it's a simple way to check that your code is working. This has been the go-to example for decades.
But there’s no rule that says you must write Hello, World!. If you’d rather write Hello, Computer! or something else, feel free to do that. The key thing is getting comfortable with printing to the screen.
For example:
print("Hello, World!")or you could just as easily do:
print("Hello, Computer!")
In the code:
#include
using namespace std;
int main() {
// create a variable
double number = 83.13;
// create a pointer variable
double* pt;
// assign address to pointer
pt = &number;
// print pointer pt
cout << pt;
return 0;
} The reason the pointer needs to be a double* is that the variable number is of type double.
In C++, the type of a pointer should always match the type of the variable it points to. So if number were an int, then the pointer should also be an int*.
Here's a quick comparison to help make it clearer:
int a = 5;
int* ptr1 = &a; // OK: both are int
double b = 6.2;
double* ptr2 = &b; // OK: both are double
double* wrongPtr = &a; // Not OK: types don’t match (int vs double)Using the correct pointer type ensures that the program knows how much memory to access and interpret properly. For instance, a double typically uses more bytes than an int, and a mismatch can lead to unexpected behavior.

It's not mandatory to know HTML or CSS before getting started with JavaScript.
JavaScript is a versatile language — it’s used for everything from making web pages interactive to building servers, mobile apps, and even games. So if you're learning it for general programming purposes (like game development or backend work), you can absolutely start without knowing any HTML or CSS.
That said, if your goal is to build websites or web applications, having a basic understanding of HTML and CSS will definitely make things easier.
HTML provides the structure of a webpage (like headings, paragraphs, images).
CSS handles the styling (like colors, fonts, layouts).
JavaScript adds interactivity (like responding to clicks, form submissions, animations).
Since JavaScript often works closely with HTML and CSS in web development, knowing a little bit about them will help you understand where and how to apply JavaScript effectively.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer
