take long long input in c

To take a long long input in C, you can use the scanf function with the %lld format specifier. Here's an example code snippet that demonstrates how to do this:

#include <stdio.h>

int main() {
    long long num;

    printf("Enter a long long number: ");
    scanf("%lld", &num);

    printf("You entered: %lld\n", num);

    return 0;
}

Let's break down the code and explain each step:

  1. First, we include the necessary header file stdio.h, which provides the standard input/output functions like printf and scanf.

  2. Then, we define the main function, which is the entry point of a C program.

  3. Inside the main function, we declare a variable num of type long long, which can hold large integer values.

  4. We use printf to display a prompt message asking the user to enter a long long number.

  5. The scanf function is used to read the input from the user. We pass the %lld format specifier to indicate that we are expecting a long long input. The & operator is used to get the address of the num variable, so that scanf can store the input value at that address.

  6. After reading the input, we use printf to display the entered value using the %lld format specifier.

  7. Finally, we return 0 to indicate successful program execution.

By following these steps, you can take a long long input in C using the scanf function.