C Programming

⌘K
  1. Home
  2. Docs
  3. C Programming
  4. Data Input and Output
  5. Conversion Specifications in C

Conversion Specifications in C

Conversion Specifications in C are used in formatted I/O functions like printf() and scanf() to define the type of data to be read or written.

Common Format Specifiers:

Conversion Specifications in C

Example:

#include <stdio.h>

int main() {
    int age;
    float height;
    char grade;

    printf("Enter your age, height and grade (e.g. 20 5.9 A): ");
    scanf("%d %f %c", &age, &height, &grade);

    printf("You entered: Age = %d, Height = %.1f, Grade = %c\n", age, height, grade);
    return 0;
}

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *