Skip to content

ki001.c

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>
int main()
{
    // testing number
    int num, len = -13 /* here minus 13 because we will remove the massage characters in line 10 */;
    printf("Enter a number to get the length : ");
    scanf("%d", &num);
    len += printf("Your input : %d", num); // here the "Your input : ", this 13 characters are extra
    printf("\nLength : %d", len);

    // testing char
    char a[20];
    len = -13;
    while (getchar() != '\n')
        ;
    printf("\nEnter a word to get the length : ");
    scanf("%19s", &a);
    len += printf("Your input : %s", a);  // here the "Your input : ", this 13 characters are extra
    printf("\nLength : %d", len);
    return 0;
}