-->

C Programming Day 2 : Variables, Variable Rules & Data Types

C Programming Day 2 (Part 1)




    After learning the basics of C programming and writing your first "Hello, World!" program in Day 1, it's time to explore one of the most important concepts in programming—Variables and Data Types.

    Every C program works with data. Whether you're creating a calculator, a banking application, or a game, you'll need a way to store and manipulate information. That's where variables and data types come in.

    By the end of this lesson, you'll understand:

    • What variables are
    • How to declare and initialize variables
    • Rules for naming variables
    • Types of variables in C
    • Data types and their sizes
    • Choosing the correct data type
    • Practical coding examples
    • Common beginner mistakes


    What is a Variable?

    A variable is a named memory location used to store data that can change while a program is running.

    Think of a variable as a container.

    Just as a bottle stores water, a variable stores information such as numbers, characters, or decimal values.

    Example:

    int age = 20;

    Here:

    • int → Data type
    • age → Variable name
    • 20 → Stored value

    Why Do We Need Variables?

    Variables allow programs to:
    • Store user information
    • Perform calculations
    • Save temporary results
    • Update values during execution
    • Process input and output
    Without variables, programs would not be able to remember information.


    Declaring Variables

    Before using a variable, it must be declared.

    Syntax
    data_type variable_name;
    Example
    int age;
    float salary;
    char grade;


    Initializing Variables

    Initialization means assigning a value when the variable is created.
    int age = 21;
    float price = 150.75;
    char grade = 'A';

    Initialization helps prevent unexpected values in your program.



    Declaring Multiple Variables

    You can declare several variables of the same type in one statement.
    int x, y, z;
    float length, width;
    char firstLetter, lastLetter;


    Updating Variable Values

    Variable values can change during program execution.
    #include <stdio.h>
    
    int main()
    {
        int marks = 60;
    
        printf("Marks = %d\n", marks);
    
        marks = 90;
    
        printf("Updated Marks = %d", marks);
    
        return 0;
    }
    Output
    Marks = 60
    Updated Marks = 90


    Variable Naming Rules

    Choosing meaningful variable names makes your code easier to read.

    Rule 1: Start with a Letter or Underscore

    Correct
    age
    _name
    studentMarks
    Wrong
    2age
    5marks

    Rule 2: Do Not Use Spaces

    Correct
    studentName
    student_name
    Wrong
    student name

    Rule 3: Do Not Use Special Characters

    Correct
    price
    totalAmount
    Wrong
    price#
    salary@

    Rule 4: Keywords Cannot Be Variable Names

    Wrong
    int if;
    Correct
    int total;

    Rule 5: Variable Names Are Case Sensitive

    age
    Age
    AGE
    These are three different variables.

    Rule 6: Use Meaningful Names

    Good
    studentAge
    totalPrice
    employeeSalary
    Avoid
    a
    x
    abc
    unless used as temporary loop variables.

    Best Practices for Variable Names

    Use descriptive names such as:


    studentName
    studentID
    employeeSalary
    monthlyIncome
    totalMarks
    averageScore

    Good naming improves readability and simplifies debugging.


    Types of Variables in C

    1. Local Variables

    Declared inside a function.
    int main()
    {
        int age = 20;
    
        return 0;
    }
    A local variable is accessible only within that function.

    2. Global Variables

    Declared outside every function.
    #include <stdio.h>
    
    int marks = 100;
    
    int main()
    {
        printf("%d", marks);
    
        return 0;
    }
    Global variables can be accessed by all functions in the same file.

    3. Static Variables

    Static variables retain their value between function calls.
    static int count = 0;

    4. Register Variables

    Stored in CPU registers whenever possible for faster access.
    register int i;

    5. Extern Variables

    Used to access global variables defined in another source file.
    extern int total;

    What is a Data Type?

    A data type tells the compiler:

    • What type of data will be stored.
    • How much memory to allocate.
    • What operations are allowed on the data.

    Every variable in C must have a data type.


    Basic Data Types in C

    Data Type                            Description                Example
    int                              Integer numbers                      10
    char                             Single character                      'A'
    float                             Decimal number                    3.14
    double                              Large decimal number             3.141592653
    void                           No value                 Functions

    Integer Data Type (int)

    Stores whole numbers.

    Example
    int age = 22;
    int marks = 95;
    Output
    22
    95

    Character Data Type (char)

    Stores a single character.
    char grade = 'A';
    char gender = 'M';
    Always use single quotation marks.

    Correct
    'A'
    Wrong
    "A"

    Float Data Type

    Stores decimal values.
    float temperature = 35.7;
    float price = 120.50;
    Float provides approximately 6–7 decimal digits of precision.

    Double Data Type

    Stores larger decimal numbers with greater precision.
    double pi = 3.141592653589793;

    Double is preferred when higher precision is required.


    Void Data Type

    Represents the absence of a value.

    Example
    void displayMessage()
    {
        printf("Welcome");
    }

    Size of Basic Data Types

    The exact size depends on your compiler and system architecture, but commonly:

    Data Type                  Typical Size
    char                    1 Byte
    int                    4 Bytes
    float                    4 Bytes
    double                    8 Bytes

    Using sizeof Operator

    The sizeof operator returns the memory occupied by a data type or variable.

    Example
    #include <stdio.h>
    
    int main()
    {
        printf("%zu\n", sizeof(int));
        printf("%zu\n", sizeof(float));
        printf("%zu\n", sizeof(double));
        printf("%zu\n", sizeof(char));
    
        return 0;
    }

    Choosing the Right Data Type

    Use:
    • int → Whole numbers
    • char → Single characters
    • float → Decimal values with moderate precision
    • double → Decimal values requiring higher precision
    Choosing the correct data type improves memory efficiency and program performance.

    Complete Example

    #include <stdio.h>
    
    int main()
    {
        int age = 20;
        float height = 5.8;
        char grade = 'A';
        double salary = 35000.75;
    
        printf("Age = %d\n", age);
        printf("Height = %.1f\n", height);
        printf("Grade = %c\n", grade);
        printf("Salary = %.2lf\n", salary);
    
        return 0;
    }
    Output
    Age = 20
    Height = 5.8
    Grade = A
    Salary = 35000.75

    Common Beginner Mistakes

    Forgetting to Initialize Variables

    int age;
    This variable may contain an undefined value until one is assigned.

    Using Double Quotes for Characters

    Wrong
    char grade = "A";
    Correct
    char grade = 'A';

    Using Reserved Keywords

    Wrong
    int while;
    Correct
    int totalMarks;

    Storing Decimal Values in an Integer

    Wrong

    int price = 25.75;

    Correct

    float price = 25.75;

    Practice Exercises

    1. Declare variables to store your name's first letter, age, and height.
    2. Create three integer variables and print their values.
    3. Store your exam marks using an int variable.
    4. Store the value of π using a double.
    5. Use the sizeof operator to display the size of char, int, float, and double.

    What's Next?

    In Part 2 (Day 2), you'll learn:

    Keep practicing these concepts before moving on, as variables and data types form the foundation of every C program you'll write.



    C Programming – Day 2 (Part 2)

    Learn C Constants, Keywords & Input Output Functions


    Welcome to Part 2 of Day 2 in our C Programming Full Course. In Part 1, you learned about variables and data types. Now it's time to understand constants, keywords, and input/output (I/O) functions, which are essential for writing interactive C programs.

    By the end of this lesson, you will learn:

    • What constants are
    • Types of constants in C
    • Using the const keyword
    • Using #define for symbolic constants
    • C reserved keywords
    • Input and Output functions
    • printf()
    • scanf()
    • getchar()
    • putchar()
    • puts()
    • Safe alternatives to deprecated functions
    • Practical coding examples
    • Common beginner mistakes
    • Best practices

    What is a Constant?

    A constant is a value that cannot be changed during program execution.

    Unlike variables, constants remain fixed throughout the program.

    Example:

    const float PI = 3.14159;

    Here, the value of PI cannot be modified after it has been declared.

    Why Use Constants?

    Constants make programs:

    • Easier to read
    • Easier to maintain
    • More secure
    • Less error-prone
    • More reusable

    Instead of writing the same value repeatedly, define it once as a constant.


    Types of Constants in C

    C supports several types of constants.

    1. Integer Constants

    Whole numbers without decimal points.

    Examples
    100
    -25
    5000
    0

    2. Floating-Point Constants

    Numbers containing decimal points.

    Examples
    3.14
    25.75
    0.001
    100.50

    3. Character Constants

    A single character enclosed in single quotation marks.

    Examples
    'A'
    'Z'
    '5'
    '#'

    4. String Constants

    A sequence of characters enclosed in double quotation marks.

    Examples
    "Hello"
    "C Programming"
    "Welcome"

    5. Enumeration Constants

    Created using the enum keyword.

    Example
    enum Days
    {
        MONDAY,
        TUESDAY,
        WEDNESDAY
    };

    The const Keyword

    The const keyword creates variables whose values cannot be changed.

    Example

    #include <stdio.h>
    
    int main()
    {
        const int MAX_USERS = 100;
    
        printf("%d", MAX_USERS);
    
        return 0;
    }

    Attempting to modify a const variable causes a compilation error.

    Wrong

    MAX_USERS = 200;

    Symbolic Constants Using #define

    The preprocessor directive #define creates symbolic constants before compilation.

    Syntax

    #define NAME value

    Example

    #include <stdio.h>
    
    #define PI 3.14159
    
    int main()
    {
        printf("%.5f", PI);
    
        return 0;
    }

    const vs #define

    Feature                      const                   #define
    Data Type                       Yes                      No
    Memory Allocation                       Yes                      No
    Type Checking                       Yes                      No
    Compiler Support                     Better                  Limited
    Debugging                     Easier                   Harder

    For most modern C programs, const is generally preferred when an actual typed constant is needed.


    What are Keywords?

    Keywords are reserved words that have predefined meanings in the C language.

    You cannot use them as variable names, function names, or identifiers.

    Example

    Wrong

    int if = 10;

    Correct

    int marks = 10;

    Common C Keywords

    The classic C language includes these reserved keywords:

    auto
    break
    case
    char
    const
    continue
    default
    do
    double
    else
    enum
    extern
    float
    for
    goto
    if
    int
    long
    register
    return
    short
    signed
    sizeof
    static
    struct
    switch
    typedef
    union
    unsigned
    void
    volatile
    while

    Categories of Keywords

    Data Types

    • int
    • char
    • float
    • double
    • void

    Decision Making

    • if
    • else
    • switch
    • case

    Loops

    • for
    • while
    • do

    Storage Classes

    • auto
    • register
    • static
    • extern

    Others

    • return
    • break
    • continue
    • sizeof
    • typedef
    • const
    • volatile

    Input and Output Functions

    Programs become useful when they can communicate with users.

    The Standard Input/Output library (stdio.h) provides functions for reading input and displaying output.

    printf()

    The printf() function displays output on the screen.

    Syntax

    printf("message");

    Example

    #include <stdio.h>
    
    int main()
    {
        printf("Welcome to C Programming!");
    
        return 0;
    }

    Output

    Welcome to C Programming!

    Printing Multiple Values

    #include <stdio.h>
    
    int main()
    {
        int age = 20;
    
        printf("Age = %d", age);
    
        return 0;
    }

    Output

    Age = 20

    scanf()

    The scanf() function reads user input.

    Syntax

    scanf("format", &variable);

    Example

    #include <stdio.h>
    
    int main()
    {
        int age;
    
        printf("Enter your age: ");
        scanf("%d", &age);
    
        printf("Your age is %d", age);
    
        return 0;
    }

    Sample Output

    Enter your age: 22
    Your age is 22

    Why is '&' Used in scanf()?

    The & (address-of operator) passes the memory address of a variable to scanf() so it can store the user's input in that variable.

    Example

    scanf("%d", &age);

    Without &, the program will not correctly store the value for most basic variable types.

    Reading Multiple Inputs

    #include <stdio.h>
    
    int main()
    {
        int a, b;
    
        printf("Enter two numbers: ");
        scanf("%d %d", &a, &b);
    
        printf("Sum = %d", a + b);
    
        return 0;
    }

    getchar()

    Reads a single character from the keyboard.

    Example

    #include <stdio.h>
    
    int main()
    {
        char letter;
    
        printf("Enter a character: ");
        letter = getchar();
    
        printf("You entered: ");
        putchar(letter);
    
        return 0;
    }

    putchar()

    Displays a single character.

    Example

    putchar('A');

    Output

    A

    puts()

    Displays a string followed by a newline.

    Example

    #include <stdio.h>
    
    int main()
    {
        puts("Welcome to ZAREEN TECH WAVE");
    
        return 0;
    }

    Output

    Welcome to ZAREEN TECH WAVE

    A Note About gets()

    Older books often show gets() for reading strings. Do not use it in new programs.

    gets() was removed from the C standard because it cannot prevent buffer overflow, making it unsafe.

    Use fgets() instead.

    Example

    char name[50];
    
    fgets(name, sizeof(name), stdin);

    Complete Input & Output Program

    #include <stdio.h>
    
    int main()
    {
        int age;
        float salary;
        char grade;
    
        printf("Enter Age: ");
        scanf("%d", &age);
    
        printf("Enter Salary: ");
        scanf("%f", &salary);
    
        printf("Enter Grade: ");
        scanf(" %c", &grade);
    
        printf("\n----- Student Information -----\n");
        printf("Age    : %d\n", age);
        printf("Salary : %.2f\n", salary);
        printf("Grade  : %c\n", grade);
    
        return 0;
    }

    Sample Output

    Enter Age: 22
    Enter Salary: 25000.50
    Enter Grade: A
    
    ----- Student Information -----
    Age    : 22
    Salary : 25000.50
    Grade  : A

    Common Beginner Mistakes

    Forgetting '&' with scanf()

    Wrong

    scanf("%d", age);

    Correct

    scanf("%d", &age);

    Using gets()

    Avoid

    gets(name);

    Use

    fgets(name, sizeof(name), stdin);

    Using Keywords as Variable Names

    Wrong

    int return;

    Correct

    int totalMarks;

    Trying to Change a Constant

    Wrong

    const int MAX = 100;
    
    MAX = 200;

    Constants declared with const cannot be reassigned.


    Best Practices

    • Use const for values that should never change.
    • Prefer meaningful constant names such as MAX_STUDENTS or PI.
    • Use fgets() instead of deprecated gets().
    • Always validate user input where practical.
    • Include <stdio.h> when using standard input/output functions.
    • Use clear prompts before calling scanf().

    Practice Exercises

    Exercise 1

    Create a constant named PI and print its value.

    Exercise 2

    Write a program to input your age and display it.

    Exercise 3

    Read two integers from the user and print their sum.

    Exercise 4

    Read a character using getchar() and display it using putchar().

    Exercise 5

    Create a program that uses both const and #define in the same source file.


    Quick Quiz

    1. What is a constant in C?

    Answer: A value that cannot be changed during program execution.

    2. Which keyword creates a constant variable?

    Answer: const

    3. Which function displays output?

    Answer: printf()

    4. Which function reads formatted input?

    Answer: scanf()

    5. Which function is recommended instead of gets()?

    Answer: fgets()


    Summary

    Congratulations! You have completed Part 2 of Day 2.

    In this lesson, you learned:

    • What constants are
    • Types of constants
    • const keyword
    • #define symbolic constants
    • C reserved keywords
    • Standard input and output functions
    • printf()
    • scanf()
    • getchar()
    • putchar()
    • puts()
    • Why fgets() is safer than gets()
    • Common mistakes and coding best practices

    In Part 3, you'll learn Format Specifiers, Escape Sequences, practical coding examples, exercises, To complete Day 2 of your C Programming course.


    C Programming – Day 2 (Part 3)

    Learn Format Specifiers & Escape Sequences in C


    Welcome to the final part of Day 2 in our C Programming Full Course 2026. In the previous lessons, you learned about variables, data types, constants, keywords, and input/output functions. Now, you'll explore Format Specifiers and Escape Sequences, which are essential for displaying and formatting data correctly in C programs.

    By the end of this lesson, you will learn:

    • What Format Specifiers are
    • Common Format Specifiers in C
    • Escape Sequences
    • Practical Programming Examples
    • Common Beginner Mistakes
    • Practice Exercises
    • Quiz
    • Conclusion
    • Frequently Asked Questions (FAQs)

    What are Format Specifiers?

    Format Specifiers are special symbols used with functions like printf() and scanf() to tell the compiler what type of data should be displayed or read.

    Every data type has its own format specifier.

    Example:

    int age = 20;
    printf("%d", age);

    Output

    20

    Here, %d tells printf() to display an integer value.

    Why are Format Specifiers Important?

    Format specifiers help the compiler:

    • Display the correct data type
    • Read user input correctly
    • Format output professionally
    • Prevent unexpected results

    Common Format Specifiers in C

    SpecifierData Type  Example
    %d          int       25
    %i          int       25
    %c         char       A
    %f         float     12.50
    %lf        double   3.141592
    %s        String     Hello
    %u     unsigned int     250
    %x    Hexadecimal      FF
    %o         Octal      75
    %p   Memory Address    0x7ffc...

    Integer Format Specifier

    #include <stdio.h>
    
    int main()
    {
        int number = 100;
    
        printf("%d", number);
    
        return 0;
    }

    Output

    100

    Character Format Specifier

    char grade = 'A';
    
    printf("%c", grade);

    Output

    A

    Float Format Specifier

    float price = 250.75;
    
    printf("%f", price);

    Output

    250.750000

    Controlling Decimal Places

    float pi = 3.14159265;
    
    printf("%.2f", pi);

    Output

    3.14

    More examples:

    printf("%.1f", pi);
    printf("%.3f", pi);
    printf("%.4f", pi);

    Output

    3.1
    3.142
    3.1416

    Double Format Specifier

    double salary = 25000.56789;
    
    printf("%.2lf", salary);

    Output

    25000.57

    String Format Specifier

    char name[] = "ZAREEN TECH WAVE";
    
    printf("%s", name);

    Output

    ZAREEN TECH WAVE

    Reading Data with scanf()

    int age;
    
    scanf("%d", &age);

    Other examples

    scanf("%f", &price);
    
    scanf("%lf", &salary);
    
    scanf("%c", &grade);
    
    scanf("%s", name);

    What are Escape Sequences?

    Escape sequences are special character combinations beginning with a backslash (\). They perform special formatting tasks.

    Common Escape Sequences

    Escape Sequence              Meaning
    \n            New Line
    \t            Horizontal Tab
    \\            Backslash
    \"            Double Quote
    \'            Single Quote
    \r           Carriage Return
    \b           Backspace
    \a           Alert Sound

    New Line (\n)

    printf("Hello\nWorld");

    Output

    Hello
    World

    Tab (\t)

    printf("Name\tAge");

    Output

    Name    Age

    Printing Double Quotes

    printf("\"C Programming\"");

    Output

    "C Programming"

    Printing a Backslash

    printf("C:\\Program Files");

    Output

    C:\Program Files

    Practical Example 1

    #include <stdio.h>
    
    int main()
    {
        char name[30];
        int age;
    
        printf("Enter your name: ");
        scanf("%29s", name);
    
        printf("Enter your age: ");
        scanf("%d", &age);
    
        printf("\nName : %s", name);
        printf("\nAge  : %d", age);
    
        return 0;
    }


    Practical Example 2

    Student Information

    #include <stdio.h>
    
    int main()
    {
        char name[30];
        int roll;
        float marks;
    
        printf("Enter Name : ");
        scanf("%29s", name);
    
        printf("Enter Roll : ");
        scanf("%d", &roll);
    
        printf("Enter Marks : ");
        scanf("%f", &marks);
    
        printf("\n------ Student Information ------\n");
        printf("Name  : %s\n", name);
        printf("Roll  : %d\n", roll);
        printf("Marks : %.2f\n", marks);
    
        return 0;
    }


    Practical Example 3

    Area of a Rectangle

    #include <stdio.h>
    
    int main()
    {
        float length, width, area;
    
        printf("Enter Length : ");
        scanf("%f", &length);
    
        printf("Enter Width : ");
        scanf("%f", &width);
    
        area = length * width;
    
        printf("Area = %.2f", area);
    
        return 0;
    }

    Common Beginner Mistakes

    Using the Wrong Format Specifier

    Wrong

    float price = 25.5;
    
    printf("%d", price);

    Correct

    printf("%f", price);

    Forgetting '&' in scanf()

    Wrong

    scanf("%d", age);

    Correct

    scanf("%d", &age);

    Forgetting \n

    Without a new line, output can appear on the same line and become harder to read.

    Using %s for Multiple Words

    scanf("%s", name);

    This reads only the first word.

    To read an entire line, use fgets().

    fgets(name, sizeof(name), stdin);

    Best Practices

    • Match each variable with the correct format specifier.
    • Limit %s input width to help avoid buffer overflows (for example, %29s for a 30-character array).
    • Use fgets() when reading sentences or names with spaces.
    • Use %.2f for currency values.
    • Keep your output neatly formatted using \n and \t.

    Practice Exercises

    Exercise 1

    Create a program that displays your name, age, and city using format specifiers.

    Exercise 2

    Take two numbers as input and display their sum.

    Exercise 3

    Display the multiplication table of a number entered by the user.

    Exercise 4

    Input a student's name, roll number, and marks, then print them in a formatted report.

    Exercise 5

    Create a simple calculator using +, -, *, and /.


    Mini Project

    Student Result Card

    Create a program that asks the user for:

    • Student Name
    • Roll Number
    • Marks in Three Subjects

    Then display:

    • Total Marks
    • Average Marks
    • Percentage

    Use proper formatting with:

    • %d
    • %f
    • %s
    • \n
    • \t

    Quick Quiz

    1. Which format specifier is used for integers?

    Answer: %d

    2. Which format specifier is used for characters?

    Answer: %c

    3. Which format specifier is used for strings?

    Answer: %s

    4. What does \n do?

    Answer: Moves the cursor to a new line.

    5. Which escape sequence inserts a horizontal tab?

    Answer: \t

    6. Which function is used to display output?

    Answer: printf()

    7. Which function is used to read formatted input?

    Answer: scanf()

    8. Which function is recommended for reading a full line of text?

    Answer: fgets()


    Day 2 Summary

    Congratulations! 🎉

    You have successfully completed Day 2 of the C Programming Full Course.

    Today you learned:

    • Variables
    • Data Types
    • Variable Naming Rules
    • Constants
    • const and #define
    • C Keywords
    • Input and Output Functions
    • printf()
    • scanf()
    • getchar()
    • putchar()
    • puts()
    • Format Specifiers
    • Escape Sequences
    • Practical Coding Examples
    • Common Mistakes
    • Best Practices

    These concepts form the foundation for writing almost every C program.


    Conclusion

    Excellent work on completing Day 2 of your C Programming journey!

    You now understand how to store data using variables, choose the correct data types, define constants, use C keywords appropriately, accept user input, display formatted output, and apply format specifiers and escape sequences to create clear and professional programs.

    Take time to practice each example and modify the programs on your own. The more you experiment with code, the faster you'll build confidence and improve your programming skills.

    In Day 3, we'll explore Operators in C, including Arithmetic, Relational, Logical, Assignment, Increment/Decrement, Bitwise, and Conditional Operators. These operators are the building blocks for performing calculations, making decisions, and controlling program behavior.

    Keep coding, keep practicing, and continue your learning journey with the C Programming Full Course!


    Frequently Asked Questions (FAQ)

    What is a variable in C?
    A variable is a named memory location used to store data that can change during program execution.
    What are the rules for naming variables in C?
    Variable names must begin with a letter or underscore, cannot contain spaces or special characters, and cannot use reserved keywords.
    What are data types in C?
    Data types define the kind of data a variable can store, such as integers, characters, floating-point numbers, and double-precision values.
    What is the difference between int and float?
    int stores whole numbers, while float stores decimal numbers with single precision.
    What is the sizeof operator in C?
    The sizeof operator returns the amount of memory occupied by a data type or variable in bytes.
    What is a constant in C?
    A constant is a fixed value that cannot be changed during program execution.
    What is the difference between const and #define?
    const creates a typed constant managed by the compiler, while #define creates a symbolic constant using the preprocessor.
    What is a variable in C?
    A variable is a named memory location used to store data that can change during program execution.
    What are the rules for naming variables in C?
    Variable names must begin with a letter or underscore, cannot contain spaces or special characters, and cannot use reserved keywords.
    What are keywords in C?
    Keywords are reserved words with predefined meanings that cannot be used as variable or function names.
    What is printf() used for?
    printf() displays formatted output to the screen.
    Why is '&' used with scanf()?
    The ampersand (&) passes the memory address of a variable so that scanf() can store the user's input.
    What is a format specifier in C?
    Format specifiers are placeholders used by printf() and scanf() to display or read specific data types.
    What does %d mean in C?
    %d is the format specifier used for integer (int) values.
    What are escape sequences?
    Escape sequences are special characters beginning with a backslash, such as \n for a new line and \t for a horizontal tab.
    Which format specifier is used for float?
    %f is used for float values, while %lf is used with scanf() for reading double values.
    Why are format specifiers important?
    They ensure data is correctly displayed and read according to its data type, helping prevent formatting and input errors.

    0/Post a Comment/Comments

    Thank You For Visit My Website.
    I Will Contact As Soon As Possible.