KI001.c
Source Code
c
#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;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
● Author - Amit Dutta · Updated - 12 Dec 2025