Standard Library Functions in C
Standard Library Functions in C
Library Functions in C
Introduction
• #include <stdio.h>
• #include <string.h>
• int main() {
• char str[] = "Hello";
• printf("Length: %d", strlen(str));
• return 0;
•}
Program 2: Absolute Value
• #include <stdio.h>
• #include <stdlib.h>
• int main() {
• int num = -10;
• printf("Absolute Value: %d", abs(num));
• return 0;
•}
Program 3: Square Root
• #include <stdio.h>
• #include <math.h>
• int main() {
• double num = 25.0;
• printf("Square Root: %lf", sqrt(num));
• return 0;
•}
MCQ Questions
Which library function is used to find the length of a string?
a) Strlen
b) Sizeof
c) Strcmp
d) Strcat