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.

Hi! You usually should not add \n after %d in scanf.
%d already skips leading whitespace (spaces, tabs, newlines). If you write scanf("%d\n", &x);, that \n tells scanf to keep waiting for more whitespace after the number, and it can look like the program is stuck until you press Enter again or type something else.
So use this:
scanf("%d", &ages[i]);
If you want each input on a new line, that’s handled by how the user types, not by adding \n to scanf.
Hello there! Yes, you can replace ++index with index++ in your loop without affecting the output in this case. Both of these operators are used to increment the value of index by 1.
But they work slightly differently in terms of when the increment happens:
++index(pre-increment): This incrementsindexbefore its value is used in the current expression.index++(post-increment): This incrementsindexafter its current value is used in the expression.
However, in the context of your for loop:
for (int index = 0; index < 5; index++) {
printf("%d\n", numbers[index]);
}
You won't notice a difference because index is being evaluated only for the loop condition (index < 5) before entering the loop body. In a loop like this, both pre-increment and post-increment will yield the same output when printing the elements of the array:
1
2
3
4
5
So, you can use either style; you just might prefer one for readability or personal habit. Keep practicing, and let me know if you have any more questions!

Hello Varun, really nice question.
A lot of beginners run into this when they start working with functions in C, so you’re definitely on the right track noticing it.
Here’s the simple idea:
If you write a function like this:
int getProduct(float a, float b)
C expects that function to return an int, no matter what you actually calculate inside it. So even if a * b produces a floating-point value, C will convert it to an integer when returning it. That’s why the decimal part disappears.
If you want the full, precise result, you need the function to return a floating-point type:
double getProduct(double a, double b) {
return a * b;
}
This keeps the decimal values and avoids losing accuracy.
And one more thing students often miss:
You have to actually use the returned value, otherwise it's wasted:
double result = getProduct(3.5, 4.6);
printf("Product: %.2f\n", result);
If anything about return types still feels unclear, feel free to ask — I’m happy to help you understand it fully.

Hello Ivan, really nice question.
It’s easy to mix up the idea of a function “returning” with what \n does in a print statement. They sound similar, but they’re completely different things.
When you write:
printf("Hey\nHow are you?");
the \n does not return from the function. It doesn’t stop anything, and it doesn’t exit the print. All it does is tell the output: start a new line here. So the text comes out like this:
Hey
How are you?
The printing continues normally after the newline.
A real return is something you do with a return statement inside a function, not with \n.
If you want more examples or want to see how multiple \n behave, I’m happy to show you.

Hello Zade, really nice question.
The reason the function is defined as int instead of void is that it actually produces a value — the sum. Whenever a function calculates something and you want to use that result later in the program, the function needs a return type that matches the kind of value it gives back. In this case, the sum of natural numbers is an integer, so the function returns an int.
A void function is different. It performs an action but doesn’t hand anything back. For example, a function that only prints something to the screen doesn’t need to return a value, so void makes sense there.
So the rule is simple:
If the function gives back a value, choose a matching return type.
If it doesn’t return anything, use void.
If you have further questions, I'm here to help.

It’s not a bug. Your count never changes, so count <= 3 stays true forever.
Buggy code:
#include
int main() {
int count = 1;
while (count <= 3) {
printf("I am inside a loop.\n");
printf("Looping is interesting.\n");
}
return 0;
}
Output (repeats forever):
I am inside a loop.
Looping is interesting.
...
Fix:
#include
int main() {
int count = 1;
while (count <= 3) {
printf("I am inside a loop.\n");
printf("Looping is interesting.\n");
count = count + 1;
}
return 0;
}
Output:
I am inside a loop.
Looping is interesting.
I am inside a loop.
Looping is interesting.
I am inside a loop.
Looping is interesting.
If you have more questions, I am here to help.

Hi Harkirat, in C, isdigit() returns 0 for false and any non-zero number for true, and the exact “true” number can be different depending on the system. So 2048 still just means true.
printf("%d\n", isdigit('8')); // non-zero means true (could be 2048)
If you have more questions, I am here to help.

Hi Sanskriti,
Great question. A function doesn’t need a return statement to run, but whether or not you use it depends on what the function is supposed to do.
If a function is only doing a task (like printing something or updating a value) and isn’t meant to give anything back, you don’t need a return value — that's when you define it with void.
But if you want the function to send a result back to the place it was called from, you need a return statement.
Here’s an example:
int add(int a, int b) {
return a + b;
}
int main() {
int result = add(3, 5);
printf("%d", result); // Output: 8
return 0;
}
The add function returns the sum of two numbers. That return value is stored in result and printed. Without return, the function wouldn’t send anything back, and you'd have nothing to work with.
Also, if you declare a function to return a value (like int, float, etc.) but forget to use return, you might get incorrect results or even undefined behavior.
So in short:
Use
returnwhen you need a result from the function.Skip it if the function is just doing something and doesn’t need to report back.
If you have more questions, I’m here to help.

Hi Mārtiņš,
Variables are called temporary because they only exist while the program is running. They're used to store values in memory that your program needs at that moment — like numbers, strings, or results from calculations.
Here’s a simple example:
int main() {
int score = 0;
score += 10;
printf("Current Score: %d\n", score);
return 0;
}
In this code, the variable score holds a value temporarily. Once the program finishes running, the data stored in score is gone — unless you explicitly save it somewhere, like a file or database.
So to sum up: variables help your program work with data during execution, but they don't keep that data permanently.
If you have more questions, I’m here to help.


Hi Soumyadeep,
Yes, it’s easier than it seems! Let’s take a simple example using the OR operator (||), which is one kind of logical gate.
The OR operator checks two conditions and gives true if at least one of them is true.
Here’s how it works in code:
if ((age >= 18) || (gpa > 3.5)) {
printf("You meet the criteria.\n");
}
This line means:
“If the person is 18 or older, or their GPA is above 3.5, then print the message.”
Examples:
If age is 20 and GPA is 3.0 → it prints (because age ≥ 18)
If age is 16 and GPA is 3.8 → it prints (because GPA > 3.5)
If age is 16 and GPA is 3.0 → it doesn’t print (because both are false)
So in simple terms:
OR means only one condition needs to be true for the code to run.
Let me know if you want help understanding other gates like AND or NOT — I’m here to help.
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