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
Post a Comment