ProgrammingVery hard
printf("%+d %05.1f", 5, 3.14159); What is printed?
- A. 5 003.2
- B. +5 3.1
- C. +5 003.1
- D. +5 003.14
Correct answer: C. +5 003.1
The + flag prints the sign, and %05.1f gives one decimal place with zero padding to width five, so 003.1.
More C Programming questions
- char s[] = "abc"; printf("%c", s[strlen(s) - 1]); What is printed?
- char w[] = "ab"; printf("%zu %zu", sizeof w, strlen(w)); What is printed (on any platform)?
- char a = "cat"; char b[] = "cat"; printf("%d", strcmp(a, b) == 0); What is printed?
- char buf[3] = {'a', 'b', 'c'}; printf("%.2s", buf); What is printed?
- char s[10] = "xyz"; strcpy(s + 1, "ab"); printf("%s", s); What is printed?
- char s[] = "hello"; char p = s; while (p) { if (p == 'l') p = 'L'; p++; } printf("%s", s); What is printed?