scanf() Example

 #include <stdio.h>


int main() {
    int integerInput;
    float floatInput;
    char characterInput[50];

    printf("Enter an integer: ");
    scanf("%d", &integerInput);

    printf("Enter a floating-point number: ");
    scanf("%f", &floatInput);

    printf("Enter a character or a word: ");
    scanf("%s", characterInput);

    printf("\nYou entered:\n");
    printf("Integer: %d\n", integerInput);
    printf("Float: %f\n", floatInput);
    printf("Character/Word: %s\n", characterInput);

    return 0;
}

Comments

Popular posts from this blog

History of Computer

Introduction to Computer

Computer Generation