Skip to content
- Courses
- DSA to Development
- Machine Learning & Data Science
- Generative AI & ChatGPT
- Become AWS Certified
- DSA Courses
- Data Structure & Algorithm(C++/JAVA)
- Data Structure & Algorithm(Python)
- Data Structure & Algorithm(JavaScript)
- Programming Languages
- All Courses
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Conditional Statements
- Python Loops
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Learn Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Interview Questions
- Core Java Interview Questions-Freshers
- Java Multithreading Interview Questions
- OOPs Interview Questions and Answers
- Java Exercises
- Java Quiz
- Java Projects
- Advance Java
- Spring Tutorial
- Spring Boot Tutorial
- Spring Boot Interview Questions
- Spring MVC Tutorial
- Spring MVC Interview Questions
- Hibernate Tutorial
- Hibernate Interview Questions
- Programming Languages
- JavaScript
- C++
- R Tutorial
- SQL
- PHP
- C#
- C
- Scala
- Perl
- Go Language
- Kotlin
- System Design
- System Design Tutorial
- Software Design Patterns
- System Design Roadmap
- Top 10 System Design Interview Questions and Answers
- Interview Corner
- Company Preparation
- Top Topics
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Multiple Choice Quizzes
- Aptitude for Placements
- Computer Science Subjects
- Operating System
- DBMS
- Computer Networks
- Engineering Mathematics
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- DevOps
- GIT
- AWS
- Docker
- Kubernetes
- Microsoft Azure Tutorial
- Google Cloud Platform
- Linux
- Linux Tutorial
- Linux Commands A-Z
- Linux Commands Cheatsheet
- File Permission Commands
- Linux System Administration
- Linux File System
- Linux Shell Scripting
- Linux Networking
- Linux Interview Questions
- Software Testing
- Software Testing Tutorial
- Software Engineering Tutorial
- Testing Interview Questions
- Jira
- Databases
- DBMS Tutorial
- SQL Tutorial
- PostgreSQL Tutorial
- MongoDB Tutorial
- SQL Interview Questions
- MySQL Interview Questions
- PL/SQL Interview Questions
- Android
- Android Tutorial
- Android Studio Tutorial
- Kotlin For Android
- Android Projects
- Android Interview Questions
- 6 Weeks of Android App Development
- Excel
- MS Excel Tutorial
- Introduction to MS Excel
- Data Analysis in Excel
- Basic Excel Formulas & Functions
- Data Analysis in Advanced Excel
- Workbooks
- Statistical Functions
- Data Visualization in Excel
- Pivot Tables in Excel
- Excel Spreadsheets in Python
- Basic Excel Shortcuts
- Mathematics
- Number System
- Algebra
- Linear Algebra
- Trigonometry
- Set Theory
- Statistics
- Probability
- Geometry
- Mensuration
- Logarithms
- Calculus
- DSA
- Data Structures
- Arrays
- Matrix
- Strings
- Linked List
- Stack
- Queue
- Tree
- Heap
- Hashing
- Graph
- Set Data Structure
- Map Data Structure
- Advanced Data Structure
- Data Structures Tutorial
- Algorithms
- Analysis of Algorithms
- Design and Analysis of Algorithms
- Asymptotic Analysis
- Asymptotic Notations
- Worst, Average and Best Cases
- Searching Algorithms
- Linear Search
- Binary Search
- Searching Algorithms Tutorial
- Sorting Algorithms
- Selection Sort
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Counting Sort
- Radix Sort
- Bucket Sort
- Sorting Algorithms Tutorial
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- DSA Tutorial
- Practice
- All DSA Problems
- Problem of the Day
- Company Wise Coding Practice
- Amazon
- Microsoft
- Flipkart
- Explore All
- GfG SDE Sheet
- Practice Problems Difficulty Wise
- School
- Basic
- Easy
- Medium
- Hard
- Language Wise Coding Practice
- Curated DSA Lists
- Beginner's DSA Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 DP Problems
- Top 50 Graph Problems
- Top 50 Tree Problems
- Competitive Programming
- Company Wise SDE Sheets
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- DSA Cheat Sheets
- SDE Sheet
- DSA Sheet for Beginners
- FAANG Coding Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Top Interview Questions
- Puzzles
- All Puzzles
- Top 100 Puzzles Asked In Interviews
- Top 20 Puzzles Commonly Asked During SDE Interviews
- Data Science
- Python Tutorial
- R Tutorial
- Machine Learning
- Data Science using Python
- Data Science using R
- Data Science Packages
- Pandas Tutorial
- NumPy Tutorial
- Data Visualization
- Python Data Visualization Tutorial
- Data Visualization with R
- Data Analysis
- Data Analysis with Python
- Data Analysis with R
- Deep Learning
- NLP Tutorial
- Web Tech
- HTML Tutorial
- CSS Tutorial
- JavaScript Tutorial
- PHP Tutorial
- ReactJS Tutorial
- NodeJS Tutorial
- Bootstrap Tutorial
- Typescript
- Web Development Using Python
- Django
- Django Tutorial
- Django Projects
- Django Interview Questions
- Flask
- Flask Tutorial
- Flask Projects
- Flask Interview Questions
- Postman
- Github
- Cheat Sheets
- HTML Cheat Sheet
- CSS Cheat Sheet
- JavaScript Cheat Sheet
- React Cheat Sheet
- Angular Cheat Sheet
- jQuery Cheat Sheet
- Bootstrap Cheat Sheet
- Learn Complete Web Development
- C
- C Basics
- C Data Types
- C Operators
- C Input and Output
- C Control Flow
- C Functions
- C Arrays
- C Strings
- C Pointers
- C Preprocessors
- C File Handling
- C Programs
- C Cheatsheet
- C Interview Questions
- C MCQ
- C++
▲
Open In App Introduction to the C99 Programming Language : Part I
Last Updated : 10 Apr, 2023 Summarize Comments Improve Suggest changes Like Article Like Save Share Report Introduction:
C99 is a standardized version of the C programming language that was published in 1999 by the International Organization for Standardization (ISO). It introduced a number of new features and improvements over the previous C89 standard, including support for variable-length arrays, flexible array members, complex numbers, and new keywords such as inline and restrict.
In this first part of the introduction to C99 programming language, we will cover some of the key features and improvements that were introduced in C99.
1.Variable-Length Arrays (VLAs)
C99 introduced support for variable-length arrays (VLAs), which allows arrays to be declared with a length that is determined at runtime rather than at compile time. This can be useful in situations where the size of an array is not known until the program is executed. The syntax for declaring a VLA is similar to that of a regular array, but with empty brackets indicating that the size is not known until runtime:
C
void foo(int n) { int array[n]; // ... } |
2.Flexible Array Members (FAMs)
Flexible array members (FAMs) are another new feature in C99 that allows arrays to be declared as the last member of a struct with an unspecified size. This can be useful in situations where a struct needs to have a variable-sized array as one of its members. The syntax for declaring a FAM is similar to that of a regular array, but with empty brackets indicating that the size is not specified:
Sure, here are some advantages, disadvantages, and recommended books for learning C99:
Advantages:
- Variable-length arrays allow for more flexible memory allocation at runtime.
- Flexible array members allow for variable-sized arrays to be part of a struct.
- Complex numbers provide built-in support for complex arithmetic.
- Inline functions and the restrict keyword can improve performance.
- Designated initializers and compound literals provide a more concise and expressive way to initialize data structures.
Disadvantages:
- Not all compilers fully support C99, so some features may not be available or may require compiler-specific extensions.
- The use of variable-length arrays and flexible array members can potentially lead to memory allocation issues if not used carefully.
Recommended books:
- “The C Programming Language” by Brian W. Kernighan and Dennis M. Ritchie
- “C Programming Absolute Beginner’s Guide” by Greg Perry and Dean Miller
- “C Programming: A Modern Approach” by K. N. King
Here is an example code with output demonstrating some of the features of C99:
C
#include <stdio.h> #include <complex.h> int main() { int n = 5; int array[n]; for (int i = 0; i < n; i++) { array[i] = i; printf("%d ", array[i]); } printf("\n"); struct foo { int x; int y[]; }; struct foo* f = malloc(sizeof(struct foo) + n * sizeof(int)); f->x = 42; for (int i = 0; i < n; i++) { f->y[i] = i; printf("%d ", f->y[i]); } printf("\n"); double complex z = 3.0 + 4.0*I; printf("Real part: %f\n", creal(z)); printf("Imaginary part: %f\n", cimag(z)); inline int add(int x, int y) { return x + y; } printf("Result: %d\n", add(2, 3)); int* restrict a = malloc(n * sizeof(int)); int* restrict b = malloc(n * sizeof(int)); for (int i = 0; i < n; i++) { a[i] = i; b[i] = n - i - 1; } int sum = 0; for (int i = 0; i < n; i++) { sum += a[i] * b[i]; } printf("Result: %d\n", sum); return 0; } |
Output 0 1 2 3 4 0 1 2 3 4 Real part: 3.000000 Imaginary part: 4.000000 Result: 5 Result: 10
C99 is another name of ISO/IEC 9899:1999 standards specification for C that was adopted in 1999. This article mainly concentrates on the new features added in C99 by comparing with the C89 standard. In the development stage of the C99 standard, every element of the C language was re-examined, usage patterns were analyzed, and future demands were anticipated. C’s relationship with C++ provided a backdrop for the entire development process. The resulting C99 standard is a testimonial to the strengths of the original.
- Keywords added in C99:
- inline: C99 adds the keyword inline which is applicable to functions. If we write inline datatype function_name (param) to any function it means that we are specifying the compiler to optimize calls to that function i.e. the function’s code will be expanded inline rather than called. Example:
C
// C program to demonstrate inline keyword #include <stdio.h> inline int maximum(int a, int b) { return a > b ? a : b; } int main() { int x = 5, y = 10; printf("Maximum of %d and %d is %d", x, y, maximum(x, y)); return 0; } |
- Note: Some Compilers show undefined reference to maximum(). This inline feature is used rarely as a keyword. The above program is equivalent to the following
C
#include <stdio.h> int main() { int x = 5, y = 10; printf("Maximum of %d and %d is %d", x, y, (x > y ? x : y)); return 0; } |
Output: Maximum of 5 and 10 is 10
- Inline functions help us to create efficient code by maintaining a structured, function-based approach.
- restrict: restrict is a type qualifier applicable only for pointers. A pointer qualified by restrict is initially the only means by which the object it points to can be accessed. Access to the object by another pointer can occur only if the second pointer is based on the first. We use restrict qualifier to restrict access to the object. These are primarily used as function parameters or in malloc(). The restrict qualifier never changes the semantics of the program.
- _Bool Datatype: _Bool datatype was added in C99 standard which stores 0 and 1 values. _Bool is an integer type. Note: bool keyword in C++ and _Bool in C are different. _Bool is used rarely instead C99 defines a new header file stdbool.h which defines three macros bool, true and false.
- _Complex: C99 adds support for performing operations on complex numbers through _Complex and _Imaginary keywords. These keywords provide better support for numerical programming. Types defined in _Complex:
- float _Complex
- double _Complex
- long double _Complex
- _Imaginary: As said above, C99 adds support for performing operations on complex numbers through _Complex and _Imaginary keywords. These keywords provide better support for numerical programming. Types defined in _Complex and _Imaginary:
- float _Imaginary
- double _Imaginary
- long double _Imaginary
- Addition of Type Qualifiers: Another important aspect added in C99 is the introduction of long long and unsigned long long type modifiers. A long long int has a range of –(2^63 – 1) to +(2^63 –1). An Unsigned long long int has a minimal range starting from 0 to +(2^64 –1). This long long type allows 64-bit integers to support as a built-in type.
- Changes in Arrays: C99 added two important features to arrays:
- Variable Length Arrays: In C89 standard, the array size has to be specified using integer constants at the array declaration and array size is fixed at compile time. In C99 standard, we can declare an array whose dimensions are specified by any integer expressions whose values known at run-time. This is called Variable Length Arrays(VLA).
- Inclusion of Type Qualifiers: In C99, we can use the keyword static inside the square brackets during array declaration. This is only applied when array is declared in function parameters i.e Example:
C
int fun1(char arr[static 80]) { // code } |
- In the above example arr is always a pointer to an 80-element array i.e arr is guaranteed to point the starting element of the array of chars that contains atleast 80 elements. We can also use the keywords restrict, volatile and const inside the square brackets if that array is declared inside a function parameters. Keyword restrict specifies that the pointer is the sole initial means of access to the object. const states that the pointer always points to the same object. volatile is allowed, but it has no meaning. Example:
C
#include <stdio.h> void fun(int a[static 10]) { for (int i = 0; i < 10; i++) { a[i] += 1; printf("%d ", a[i]); } } int main() { int a[] = { 1, 2, 3, 4, 4, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10 }; fun(a); } |
- Single Line Comments: Single Line comments aren’t accepted in C89 standard. C99 standard introduces Single Line Comments which are used only when brief remarks are needed. These comments begin with // and runs to the end of the line. Eg:
C
// First Comment int a; // another comment |
- Declaration of Identifiers: According to the C89 standard, all Identifiers should be declared at the start of the code block. If we need any other identifier at the middle, we can’t declare for that instance or time. We need to declare that at the start. C99 has changed this rule as we can declare identifiers whenever we need in a code. In simple, we can see this as:
C
#include <stdio.h> int main() { int i; i = 1; int j; // this declaration is invalid in C89 standard, but valid in C99 and C++ j = 3; } |
avsadityavardhan
Follow Improve Previous Article Design Goals and Principles of Object Oriented Programming
Next Article Similar Reads
- Introduction to the C99 Programming Language : Part I Introduction: C99 is a standardized version of the C programming language that was published in 1999 by the International Organization for Standardization (ISO). It introduced a number of new features and improvements over the previous C89 standard, including support for variable-length arrays, flex 8 min read
- Introduction to the C99 Programming Language : Part III Kindly read Introduction to the C99 Programming Language (Part I) and Introduction to the C99 Programming Language (Part II) before reading this article. Addition of Library Functions: C99 provides some Additional Library functions listed below. Library Function Usage complex.h complex.h supports co 3 min read
- Introduction to Programming Languages Introduction: A programming language is a set of instructions and syntax used to create software programs. Some of the key features of programming languages include: Syntax: The specific rules and structure used to write code in a programming language.Data Types: The type of values that can be store 13 min read
- Control Structures in Programming Languages Control Structures are just a way to specify flow of control in programs. Any algorithm or program can be more clear and understood if they use self-contained modules called as logic or control structures. It basically analyzes and chooses in which direction a program flows based on certain paramete 3 min read
- C Programming Language Tutorial In this C Tutorial, you’ll learn all C programming basic to advanced concepts like variables, arrays, pointers, strings, loops, etc. This C Programming Tutorial is designed for both beginners as well as experienced professionals, who’re looking to learn and enhance their knowledge of the C programmi 8 min read
- Features of C Programming Language C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. The main features of C language include low-level access to memory, a simple set of keywords, and a clean styl 3 min read
- Learn Free Programming Languages In this rapidly growing world, programming languages are also rapidly expanding, and it is very hard to determine the exact number of programming languages. Programming languages are an essential part of software development because they create a communication bridge between humans and computers. No 9 min read
- C Programming Language Standard Introduction:The C programming language has several standard versions, with the most commonly used ones being C89/C90, C99, C11, and C18. C89/C90 (ANSI C or ISO C) was the first standardized version of the language, released in 1989 and 1990, respectively. This standard introduced many of the featur 6 min read
- Print "GeeksforGeeks" in 10 different programming languages The most elementary part of learning any computer programming language is the ability to print a desired text on the screen or console. Thus, the task of this article is to guide programmers new to any of the 10 different languages discussed below, i.e. GO, Fortran, Pascal, Scala, Perl, ADA, Ruby, K 4 min read
- A Categorical List of programming languages Programming languages are the formal language, with a set of instructions which provides the desired output. For implementing various algorithms in our machines we started using the Programming language. A set of specific instructions are used in programmable machines, rather than general programmin 7 min read
- C Programming Interview Questions (2024) At Bell Labs, Dennis Ritchie developed the C programming language between 1971 and 1973. C is a mid-level structured-oriented programming and general-purpose programming. It is one of the oldest and most popular programming languages. There are many applications in which C programming language is us 15+ min read
- C program to detect tokens in a C program As it is known that Lexical Analysis is the first phase of compiler also known as scanner. It converts the input program into a sequence of Tokens. A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.For Example: 1) Keyword 5 min read
- Benefits of C language over other programming languages C is a middle-level programming language developed by Dennis Ritchie during the early 1970s while working at AT&T Bell Labs in the USA. The objective of its development was in the context of the re-design of the UNIX operating system to enable it to be used on multiple computers. Earlier the lan 3 min read
- C Programming For Beginners - A 20 Day Curriculum! For the last 40-45 years, C is one of the most popular and highly recognized programming languages in the world. In fact, it is the first programming language of a huge number of individuals (including me!). Indeed, it is strongly recommended to start your programming journey with C language as it h 7 min read
- What is COBOL(Common Business Oriented Language)? COBOL an acronym for Common Business Oriented Language is a computer programming language, which was designed for business use. COBOL was procedural in the beginning, but since 2002, COBOL became object-oriented. COBOL was developed by Conference of Data System Languages(CODASYL). COBOL is primarily 6 min read
- Implement a Stack in C Programming Stack is the linear data structure that follows the Last in, First Out(LIFO) principle of data insertion and deletion. It means that the element that is inserted last will be the first one to be removed and the element that is inserted first will be removed at last. Think of it as the stack of plate 7 min read
- Zig - A Brief Introduction As software systems naturally become more complex, the requirement for new programming languages that are able not only to get good performance but also to be safe and to be on a modern language level increases continuously. This landscape is where Zig resumes its place among venerable low level pro 13 min read
- Commonly Asked C Programming Interview Questions | Set 2 This post is second set of Commonly Asked C Programming Interview Questions | Set 1What are main characteristics of C language? C is a procedural language. The main features of C language include low-level access to memory, simple set of keywords, and clean style. These features make it suitable for 3 min read
- Design Goals and Principles of Object Oriented Programming The fundamental goal of dealing with the complexity of building modern software naturally gives rise to several sub-goals. These sub-goals are directed at the production of quality software, including good implementations of data structures and algorithms. The article focuses on discussing design go 13 min read
Article Tags :
- C Language
- Programming Language
Like Explore More
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It !
Improvement Suggest changes Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
Suggest Changes min 4 words, max CharLimit:2000
What kind of Experience do you want to share?
Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences