From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Exploring unary operators - C Tutorial
From the course: Complete Guide to C Programming Foundations
Exploring unary operators
- [Instructor] The C Language unary operators affect only one variable. The name unary comes from the Latin unes, one. Here's the full list, including the sizeof operator, which is both an operator and a C language keyword. It deserves a bit of exploration. Sizeof works on a variable, array or a chunk of memory. It returns a size_t value, which is an unsigned positive integer, representing the number of bytes of memory the item occupies. You must include the stdio.h header file to use the size_t typedef in your code, the operator's used most often when allocating memory or dealing with pointers. In this code, six variables are declared, the four standards, char and float and double. I've also created a character array or string, and an integer array capable of holding 10 elements. For each of these items, a printf statement outputs the size they occupy in memory. Within the printf statement, the size of operator is applied to each variable or data type. The values shown here might not…
Contents
-
-
-
-
-
Working with math operators3m 13s
-
(Locked)
Challenge: Do some math50s
-
(Locked)
Solution: Do some math1m 47s
-
(Locked)
Using assignment operators1m 49s
-
(Locked)
Obeying the order of precedence3m 14s
-
(Locked)
Challenge: Get the order correct55s
-
(Locked)
Solution: Get the order correct1m 37s
-
(Locked)
Working with relational operators3m 48s
-
(Locked)
Using logical operators3m 58s
-
(Locked)
Understanding bitwise operators3m 44s
-
(Locked)
Shifting bits3m 13s
-
(Locked)
Exploring unary operators3m 3s
-
Chapter challenge: More math1m 8s
-
(Locked)
Chapter solution: More math2m 45s
-
-
-
-
-
-
-
-
-