C
  • Introduction
    • Fundamentals of a Program
    • Overview of C
    • Features of C
  • Installing Required Software
    • Setting Up VSCode for Windows
    • Setting Up VSCode for macOS
    • Setting Up VSCode for Ubuntu
  • Starting to write code
    • Compiling and Running Your Code
    • Creating Our First C Program
    • Errors and Warnings
    • Program: Writing a C Program to Display Your Name
    • Structure of a C Program
  • Basic Concepts
    • Comments in C
    • Preprocessor in C
    • The #include Statement
    • Displaying Output
    • Reading Input from the Terminal
    • Enums and Chars
    • Data Types and Variables
    • Format Specifiers
    • Command Line Arguments
    • Program: Calculating the Area of a Triangle
  • Operators
    • Converting Minutes to Years and Days
    • Basic Operators
    • Bitwise Operators
    • Program: Byte Sizes of Basic Data Types
    • cast and sizeof Operators
    • Operator Precedence
  • Control Flow
    • If-Else Statements
    • Program: Weekly Pay Calculation
    • Switch Statement
    • For Loop
    • While and Do-While Loops
    • Nested Loops and Loop Control
    • Program: Guess the Number
  • Arrays
    • Introduction to Arrays
    • Program: Prime Number Generator
    • Multidimensional Arrays
    • Program: simple Weather Program
    • Variable Length Arrays (VLAs)
  • Functions
    • Overview of Functions
    • Defining Functions
    • Arguments and Parameters
    • Returning Data from Functions
    • Variable Scoping
    • Program: Tic Tac Toe Game
    • Recursion
  • Strings
    • Defining a String
    • Constant Strings in C
    • Common String Functions
    • Program: Bubble Sort
    • Searching, Tokenizing, and Analyzing Strings
    • Converting Strings
  • Debugging
    • What is Debugging
    • Understanding the Call Stack
    • Common C Mistakes
    • Understanding Compiler Errors
  • Pointer
    • Defining Pointers
    • Accessing Pointers
    • Program: Pointer Demonstration
    • Pointers and Const
    • Void Pointers
    • String Pointers
    • Array Pointers
    • Utilizing Pointers with Functions
    • Pointer Arithmetic
  • Dynamic Memory Allocation
    • malloc, calloc, and realloc
    • Program: User Input String
    • Memory Deallocation
  • Structure
    • Structures and Arrays
    • Nested Structures
    • Structures and Pointers
    • Structures and Functions
    • Program: Structure pointers and Functions
  • File Input and Output
    • Accessing Files
    • Reading from a File
    • Program: Finding the Total Number of Lines in a Text File
    • Writing to a Text File
    • Finding Your Position in a File
    • Program: Converting Characters in a File to Uppercase
    • Program: Printing the Contents of a File in Reverse Order
  • The Standard C Library
    • Various Functions in C
    • Math Functions in C
    • Utility Functions in C
Powered by GitBook
On this page
  • Overview
  • 1. Mathematical Functions
  • a. sqrt (Square Root):
  • b. pow (Power):
  • c. fabs (Absolute Value for Floats):
  • d. ceil (Ceiling Function):
  • e. floor (Floor Function):
  • 2. String Functions
  • a. strlen (String Length):
  • b. strcpy (String Copy):
  • c. strcmp (String Compare):
  • d. strcat (String Concatenate):
  • 3. Character Functions
  • a. isalpha (Is Alphabetical):
  • b. isdigit (Is Digit):
  • c. toupper (Convert to Uppercase):
  • d. tolower (Convert to Lowercase):
  • 4. Input/Output Functions
  • a. printf (Print Formatted):
  • b. scanf (Scan Formatted):

Was this helpful?

  1. The Standard C Library

Various Functions in C

Overview

C programming language offers a variety of functions that cater to different aspects of programming, ranging from mathematical calculations to character manipulation. This section provides an overview of various functions available in C.

1. Mathematical Functions

a. sqrt (Square Root):

  • Calculates the square root of a number.

    #include <math.h>
    double sqrt(double x);

b. pow (Power):

  • Raises a number to the power of another.

    #include <math.h>
    double pow(double x, double y);

c. fabs (Absolute Value for Floats):

  • Returns the absolute value of a floating-point number.

    #include <math.h>
    double fabs(double x);

d. ceil (Ceiling Function):

  • Rounds a floating-point number to the smallest integer greater than or equal to it.

    #include <math.h>
    double ceil(double x);

e. floor (Floor Function):

  • Rounds a floating-point number to the largest integer less than or equal to it.

    #include <math.h>
    double floor(double x);

2. String Functions

a. strlen (String Length):

  • Returns the length of a string.

    #include <string.h>
    size_t strlen(const char *str);

b. strcpy (String Copy):

  • Copies the contents of one string to another.

    #include <string.h>
    char *strcpy(char *dest, const char *src);

c. strcmp (String Compare):

  • Compares two strings.

    #include <string.h>
    int strcmp(const char *str1, const char *str2);

d. strcat (String Concatenate):

  • Concatenates two strings.

    #include <string.h>
    char *strcat(char *dest, const char *src);

3. Character Functions

a. isalpha (Is Alphabetical):

  • Checks if a character is an alphabet.

    #include <ctype.h>
    int isalpha(int c);

b. isdigit (Is Digit):

  • Checks if a character is a digit.

    #include <ctype.h>
    int isdigit(int c);

c. toupper (Convert to Uppercase):

  • Converts a character to uppercase.

    #include <ctype.h>
    int toupper(int c);

d. tolower (Convert to Lowercase):

  • Converts a character to lowercase.

    #include <ctype.h>
    int tolower(int c);

4. Input/Output Functions

a. printf (Print Formatted):

  • Prints formatted output to the console.

    #include <stdio.h>
    int printf(const char *format, ...);

b. scanf (Scan Formatted):

  • Reads formatted input from the console.

    #include <stdio.h>
    int scanf(const char *format, ...);

These are just a few examples of the many functions available in C. Understanding and utilizing these functions is essential for effective C programming.

If you have specific questions or if there are additional topics you'd like to explore, feel free to ask!

PreviousThe Standard C LibraryNextMath Functions in C

Was this helpful?