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
MARCO PAOLO RODRIGUEZ TALAMANTES
last year
Marcocountry asked
Kelish Rai
Expert
last year
Kelish Rai answered

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: 42

Here,

  1. printf() asks the user to enter a number.

  2. scanf("%d", &number); takes the user's input and stores it in the number variable.

    • %d tells scanf that you're expecting an integer.

    • &number is the address of the variable where the input will be stored.

  3. Finally, printf() displays the entered number.

Note: Always remember to use & (address-of operator) before the variable name in scanf().

C
This question was asked as part of the Practice: C Programming course.
Abhilekh Gautam
Expert
last year

printf() is used to display text or values on the screen.

For Example:

printf("Hello, World");

The above code displays the text Hello, World on the screen.

I hope this clears your confusion. If you have more questions feel free to ask!

C
This question was asked as part of the Learn C Programming course.
Abhilekh Gautam
Expert
last year

In C, scanf() is used to read input from the user, while printf() is used to display output on the screen.

Think of it this way:

  • scanf() receives data (input)

  • printf() sends data to the screen (output)

Example:

#include 

int main() {
    int age;

    printf("Enter your age: ");    // Output
    scanf("%d", &age);    // Input

    printf("You are %d years old.", age);    // Output
    return 0;
}

Here, printf() first prompts the user, and then scanf() captures the input into the age variable. After that, printf() is used again to show the result.

C
This question was asked as part of the Learn C Programming course.
Abhilekh Gautam
Expert
last year

For integers, the format specifier is %d. For other types:

  • float: %f
  • double: %lf
  • char: %c

You’ll learn more about these and how to use them later in the course, so don’t worry about it for now.

Keep going, you’re doing great!

C
This question was asked as part of the Learn C Programming course.
Abhilekh Gautam
Expert
last year

Yes, C and C++ are different, though closely related. C++ is essentially an extension of the C programming language—it builds on C’s features and adds additional tools, especially object-oriented programming (OOP).

Here’s a quick breakdown:

  • C is a procedural programming language, meaning it focuses on functions and sequences of instructions.

  • C++ supports everything C does, but also includes object-oriented features like classes, inheritance, and polymorphism, which allow for more structured and reusable code.

Example in C (procedural approach):

#include 

void greet() {
    printf("Hello, world!");
}

int main() {
    greet();
    return 0;
}

Same idea in C++ (with an object-oriented approach):

#include 
using namespace std;

class Greeter {
public:
    void greet() {
        cout << "Hello, world!";
    }
};

int main() {
    Greeter g;
    g.greet();
    return 0;
}

So while the basics (like variables, loops, and syntax) are very similar, C++ gives you more tools and structure—especially useful for large, complex programs.

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

In C programming, curly braces { } are used to define the body of functions, conditional statements, and other code blocks.

Take a look at this simple program that prints "Hello, World!":

#include 

int main() {

    printf("Hello, World!");

    return 0;
}

In this example, the curly braces define the body of the main() function, where the actual code is executed.

If you're just starting out, I recommend you keep going through the course. It'll help you learn each concept step by step and build a solid foundation.

Hope this helps. If you need more clarification, feel free to ask. I'm happy to help.

C
This question was asked as part of the Learn C Programming course.
Potato Gamer
last year
Potatocountry asked
Abhilekh Gautam
Expert
last year

In this code:

#include 

int main() {

    int count = 1;

    while (count <= 3) {
        printf(""I am inside a loop.\n"");

        count++;
    }
  
    return 0;
}

count++ increments the value of the count variable by 1.

Just note that count++ is a shorthand for count = count + 1.

If you have more questions, feel free to ask.

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

Yes, you need to use printf() whenever you want to output text.

Here's an example of how you would output a greeting:


printf("Hello! How are you?");

Hope this helps! If you're still confused, feel free to ask a follow-up question below.

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