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.

  • All
  • Python
  • C
  • Java
  • CPP
  • SQL
  • JS
  • HTML
  • CSS
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Tom,

Yes, exactly — WHERE always comes before GROUP BY in SQL.

Here’s why: the WHERE clause filters the rows before any grouping happens. So only the rows that match your condition are included in the groups.

Let’s say you have this query:

SELECT department, MIN(age) AS min_age, MAX(age) AS max_age
FROM Employees
WHERE department <> 'Marketing'
GROUP BY department;

First, SQL filters out all rows where the department is 'Marketing'. Then it groups the remaining rows by department and calculates the min and max age for each group.

If you applied the WHERE after GROUP BY, it wouldn’t work — because WHERE doesn’t operate on groups. That’s what HAVING is for, if you ever need to filter after grouping.

So yes, WHERE always comes first.

If you have more questions, I am here to help.

SQL
This question was asked as part of the Learn SQL Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Konstantin,

Yes, that condition creates an infinite loop — unless something inside the loop changes n to a negative value.

Let’s break it down:

  • n == 0 is true if n is exactly 0

  • n > 0 is true if n is positive

  • or means the loop will keep running as long as either of those is true

So basically, as long as n is zero or positive, the condition stays true, and the loop won’t stop. That makes it infinite — unless you manually change n inside the loop to something negative.

If your goal is to loop only while n is positive (and stop on zero or anything less), just write:

while n > 0:

Here’s a quick example:

n = float(input())
total = 0

while n > 0:
    total += n
    n = float(input())

print(total)

This will keep adding numbers until the user enters zero or a negative value.

If you have more questions, I am here to help.

Python
This question was asked as part of the Getting started with Python course.
Kelish Rai
Expert
last year
Kelish Rai answered

In C, when you use a comparison like total > 100, it doesn’t return true or false as words — it returns a number:

  • 1 if the condition is true

  • 0 if it’s false

So if you write:

result = total > 100;

C checks if total is greater than 100. If it is, result becomes 1. If not, result becomes 0.

That’s why the output is either 0 or 1 — it's just how C handles boolean logic under the hood.

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.
Chika Lucinda Barn-Nzekwe
last year
Chikacountry asked
Kelish Rai
Expert
last year
Kelish Rai answered

Hi Chika,

int stands for integer, which means whole numbers — no decimals. Examples include 5, 42, or -100.

In most programming languages, including C and C++, int is used to declare variables that store whole numbers:

int age = 25;

That line creates a variable named age that holds the value 25.

If you have more questions, I am here to help.

SQL
This question was asked as part of the Learn SQL Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Sanskriti,

Good observation — they’re both used in printf, but for different types of data.

  • %s is used to print a string (a sequence of characters ending with \0)

  • %c is used to print a single character

Here’s an example to make it clear:

char movie[] = "Snowpiercer";

// Prints the full string
printf("The full movie title is: %s\n", movie);

// Prints the 4th character (index 3)
printf("The fourth character is: %c\n", movie[3]);

So if you're printing the entire string, use %s.
If you're just printing one character from that string — like movie[3] — use %c.

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.
Udayan Shakya
Expert
last year
Udayan Shakya answered

Hi Harkirat,

Great question — it’s something many learners wonder about.

When you write:

int intValue = (int) doubleValue;

the part (int) is called explicit type casting. You're telling the compiler clearly: "Yes, I know doubleValue is a double, and I want to convert it to an integer."

Even though you're storing the result in an int, if you skip the cast:

int intValue = doubleValue;

C will do an implicit conversion — it still works, but the compiler may give you a warning, especially if there’s a chance of losing data (like dropping decimal points).

Using (int) makes your intention clear and avoids confusion. It’s also a good habit when converting between types, especially when precision matters.

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Ramcharan,

Yes, you can use quotes around numbers in print(), but it changes what you're printing.

For example:

print(65.6)      # prints a number  
print("65.6")    # prints a string that looks like a number

Both will display 65.6, but the first one is a number, and the second is a string. Python treats them differently.

If you're just printing a value, both work. But if you want to use that value later for math, keep it as a number — don’t put it in quotes.

If you have more questions, I am here to help.

Python
This question was asked as part of the Getting started with Python course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi George,

Good question — it confuses a lot of people at first.

When you use const with an array in JavaScript, you're saying the reference to the array can’t change — not the contents.

So this is allowed:

const fruits = ["Apple", "Banana", "Orange"];
fruits[1] = "Mango";  // ✅ You can update elements

But this is not allowed:

fruits = ["Grapes", "Pineapple"];  // ❌ Error: assignment to constant variable

So const just means you can’t assign a new array to that variable. You can still update, add, or remove elements from the original array.

If you have more questions, I am here to help.

JS
This question was asked as part of the Learn JavaScript Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Miki,

Great question — this is a common source of confusion in Java.

  • == checks if two variables point to the exact same object in memory. It doesn’t care about the content — just the reference.

  • .equals() checks if the content of two strings is the same, even if they’re different objects.

Example:

String a = new String("hello");
String b = new String("hello");

System.out.println(a == b);       // false — different objects
System.out.println(a.equals(b));  // true — same content

So whenever you want to compare the actual text in two strings, always use .equals().

If you have more questions, I am here to help.

Java
This question was asked as part of the Practice: Java Basics course.
Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Suteemon,

Great question — if you want to loop through each digit of an integer (not each number in a range), you can do it using division and modulus.

Here’s how you can do it in C:

int num = 1234;

while (num > 0) {
    int digit = num % 10;  // gets the last digit
    printf("%d\n", digit); // print or process the digit
    num = num / 10;        // remove the last digit
}

This will print:

4  
3  
2  
1

If you want the digits in the original order (1, 2, 3, 4), you can store them in an array or reverse them after collecting.

Let me know if you were asking about looping over a range of numbers instead — happy to help with that too.

If you have more questions, I am here to help.

C
This question was asked as part of the Practice: C Programming course.