0% found this document useful (0 votes)
7 views609 pages

All c Merged Removed Removed

The document provides an introduction to the C programming language, developed by Dennis Ritchie in 1972, highlighting its features such as low-level memory access, fast speed, and clean syntax, making it suitable for system programming. It discusses the importance of learning C as a foundation for understanding modern programming languages and outlines the structure of a C program along with its components. Additionally, it mentions various applications of C in operating systems, embedded systems, networking, and more, while also covering the different standards of C and their respective features.

Uploaded by

rigrid45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
7 views609 pages

All c Merged Removed Removed

The document provides an introduction to the C programming language, developed by Dennis Ritchie in 1972, highlighting its features such as low-level memory access, fast speed, and clean syntax, making it suitable for system programming. It discusses the importance of learning C as a foundation for understanding modern programming languages and outlines the structure of a C program along with its components. Additionally, it mentions various applications of C in operating systems, embedded systems, networking, and more, while also covering the different standards of C and their respective features.

Uploaded by

rigrid45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 609
12181123, 203 PM C Language Introduction -GeeksforGeeks oS C Language Introduction Read Cis a procedural programming language initially developed by Dennis Ritchie in the year 1972 at Bell Laboratories of AT&T Labs. It was mainly developed a system programming language to write the UNIX operating system. Language The main features of the C language include: * General Purpose and Portable * Low-level Memory Access * Fast Speed * Clean Syntax The: fe ure make the C language suitable for sy: em programming like an operating system or compiler development. amt We use cookies to ensure you have the best browsing experience on our website. By using our Got it! site, you acknowledge that you have read and understood our Cookie Policy & Priva Policy ntps:hwww.geekstorgeeks.orgic-language-inroduction7ef=shm 12181123, 203 PM C Language Introduction -GeeksforGeeks MERN Full Stack Web Development Why Should We Learn C? Many later languages have borrowed syntax/features directly or indirectly from the C language. Like syntax of Java, PHP, JavaScript, and many other languages are mainly based on the C language. C++ is nearly a superset of C language (Only a few programs may compile in C, but not in C++) So, if a person learns C programming first, it will help him to learn any modern programming language as well. As learning C help to understand a lot of the underlying architecture of the operating system. Like pointers, working with memory locations, etc. Get Started with C Learn C fundamentals and advanced concepts, then solve practical problems right in your browser window with Educative's interactive skill path Become a C Programmer. Sign up at Educative.io with the code GEEKS10 to save 10% on your subscription. Beginning with C programming: Writing the First Program in C The following code is one of the simplest C programs that will help us the 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 ntps:ihwww.geekstorgeeks.orgic-language-inroduction/?ref=shm aint 12181123, 203 PM c include int main() { int a = 10; print#("%d", a); return 0; 3 Output 10 C Language Introduction -GeeksforGeeks Let us analyze the structure of our program line by Line. Structure of the C program After the above discu: program. By structure, it is meant that any program can be written in this structure only. Writing a C program in any other structure will hence lead to a ssion, we can formally assess the structure of a C Compilation Error. The structure of a C program is as follows: Structure of C Program (__1] #include Header int main(void) Main { printf("Hello World"); | Statement return O; Return We use cookies to ensure you have the best browsing experience on our website. By using our Policy & Privacy Policy site, you acknowledge that you have read and understood our Cool ntps:hwww.geekstorgeeks.orgic-language-inroduction7ef=shm 12181123, 203 PM C Language Introduction -GeeksforGeeks EE Components of a C Program: 1. Header Files Inclusion — Line 1 [#include ] The first and foremost component is the inclusion of the Header files in a C program. A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. All lines that start with # are processed by a preprocessor which is a program invoked by the compiler. In the above example, the preprocessor copies the preprocessed code of stdio.h to our file. The .h files are called header files in C. Some of the C Header files: * stddef-h — Defines several useful types and macros. * stdinth - Defines exact width integer types. * stdio.h — Defines core input and output functions * stdlib.h ~ Defines numeric conversion functions, pseudo-random number generator, and memory allocation * string.h ~ Defines string handling functions * math.h— Defines common mathematical functions. 2. Main Method Declaration — Line 2 [int main()] The next part of a C program is to declare the main() function. It is the entry 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 ntps:ihwww.geekstorgeeks.orgic-language-inroduction/?ref=shm am 12/8123, 208 PM C Language ntoducton- GeekstorGeoks (See this for more details). The int that was written before the main indicates the return type of main(). The value returned by the main indicates the status of program termination. See this post for more details on the return type. 3. Body of Main Method — Line 3 to Line 6 [enclosed in {}] The body of a function in the C program refers to statements that are a part of that function. It can be anything like manipulations, searching, sorting, printing, etc. A pair of curly brackets define the body of a function. All functions must start and end with curly brackets. 4. Statement — Line 4 [printf(“Hello World”);] Statements are the instructions given to the compiler. In C, a statement is always terminated by a semicolon (:). In this particular case, we use printf) function to instruct the compiler to display “Hello World” text on the screen. 5. Return Statement - Line 5 [return 0;] The last part of any C function is the return statement. The return statement refers to the return values from a function. This return statement and return value depend upon the return type of the function. The return statement in our program returns the value from main(). The returned value may be used by an operating system to know the termination status of your program. The value 0 typically means successful termination How to Execute the Above Program? In order to execute the above program, we need to first compile it using a compiler and then we can run the generated executable. There are online IDEs available for free like GeeksforGeeksIDE, that can be used to start development in C without installing a compiler. GfG Offline Programs C CBasics CData Types COperators Cinputand Output CControlFlow C Functic like Code Blocks and Dev-CPP. IDEs provide us with an environment to 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 ntps:ihwww.geekstorgeeks.orgic-language-inroduction/?ref=shm sit 1291728,208 PM C Language Invoducton-GesksorGesks 2. Linux: GCC compiler comes bundled with Linux which compiles C programs and generates executables for us to run. Code Blocks can also be used with Linux 3. macOS: macOS already has a built-in text editor where you can just simply write the code and save it with a “.c” extension. Application of C * Operating systems: C is widely used for developing operating systems such as Unix, Linux, and Windows. + Embedded systems: C is a popular language for developing embedded systems such as microcontrollers, microprocessors, and other electronic devices, + System software: C is used for developing system software such as device drivers, compilers, and assemblers. + Networking: C is widely used for developing networking applications such as web servers, network protocols, and network drivers. * Database systems: C is used for developing database systems such as Oracle, MySQL, and PostgreSQL. * Gaming: C is often used for developing computer games due to its ability to handle low-level hardware interactions. * Artificial Intelligence: C is used for developing artificial intelligence and machine learning applications such as neural networks and deep learning algorithms. * Scientific applications: C is used for developing scientific applications such as simulation software and numerical analysis tools * Financial applications: C is used for developing financial applications such as stock market analysis and trading systems. * Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above. If you have better suggestions about the products/services/tools/brands listed above or feel like something missing, please Contact Us and share your 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 ntps:hwww.geekstorgeeks.orgic-language-inroduction7ef=shm ent 12131123, 203 PM Features of C Programming Language - GeeksforGeeks 36 Features of C Programming Language GfG Offline Programs C CBasics CDataTypes COperators Cinputand Output CControlFlow C Functic 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 style, these features make C language suitable for system programming like an operating system or compiler development What are the Most Important Features of C Language? Here are some of the most important features of the C language: Procedural Language Fast and Efficient Modularity Statically Type General-Purpose Language . Rich set of built-in Operators . Libraries with Rich Functions Middle-Level Language Portability 10. Easy to Extend ©MnNAMAWNE 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 coe intps:mww.geekstorgects orgieatures-of programming tanguager?reflbp 12131123, 203 PM Features of C Programming Language - GeeksforGeeks Eeatures of C Programming Language Procedural Language Let discuss these features one by one: 1. Procedural Language In a procedural language like C step by step, predefined instructions are carried out. C program may contain more than one function to perform a particular task. New people to programming will think that this is the only way a particular programming language works. There are other programming paradigms as well in the programming world. Most of the commonly used paradigm is an object-oriented programming language. 2. Fast and Efficient 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 intps:mww.geekstorgects orgieatures-of programming tanguager?reflbp 29 1218123, 208 PM Features of © Programming Language - GeeksforGesks Newer languages like Java, python offer more features than ¢ programming language but due to additional processing in these languages, their performance rate gets down effectively. C programming language as the middle-level language provides programmers access to direct manipulation with the computer hardware but higher-level languages do not allow this. That's one of the reasons C language is considered the first choice to start learning programming languages. It’s fast because statically typed languages are faster than dynamically typed languages. 3. Modularity The concept of storing C programming language code in the form of libraries. for further future uses is known as modularity. This programming language can do very little on its own most of its power is held by its libraries. C language has its own library to solve common problems. 4, Statically Type C programming language is @ statically typed language. Meaning the type of variable is checked at the time of compilation but not at run time. This means each time a programmer types a program they have to mention the type of variables used 5. General-Purpose Language From system programming to photo editing software, the C programming language is used in various applications. Some of the common applications where it's used are as follows: * Operating systems: Windows, Linux, iOS, Android, OXS + Databases: PostgreSQL, Oracle, MySQL, MS SQL Server, etc 6. Rich set of built-in Operators 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 intps:mww.geekstorgects orgieatures-of programming tanguager?reflbp 12131123, 203 PM Features of C Programming Language - GeeksforGeeks. 7. Libraries with Rich Functions Robust libraries and functions in C help even a beginner coder to code with ease. 8. Middle-Level Language As itis a middle-level language so it has the combined form of both capabilities of assembly language and features of the high-level language. 9. Portability C language is lavishly portable as programs that are written in C language can run and compile on any system with either no or small changes. 10. Easy to Extend Programs written in C language can be extended means when a program is already written in it then some more features and operations can be added to it. Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Last Updated : 16 Jun, 2023 17 Previous Next C Language Introduction C Programming Language Standard 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 intps:mww.geekstorgects orgieatures-of programming tanguager?reflbp 1279128, 208 PM C Programming Language Stancard - GeeksforGeeks 36 GfG Offline Programs C CBasics CDataTypes COperators Cinputand Output CControlFlow C Functie Introduction: The C programming language has several standard versions, with the most commonly used ones being C89/C90, C99, C11, and C18. 1. 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 features that are still used in modern C programming, including data types, control structures, and the standard library, 2. C99 (ISO/IEC 9899:1999) introduced several new features, including variable-length arrays, flexible array members, complex numbers, inline functions, and designated initializers. This standard also includes several new library functions and updates to existing ones. 3. C11 (ISO/IEC 9899:2011) introduced several new features, including _Generic, static_assert, and the atomic type qualifier. This standard also includes several updates to the library, including new functions for math, threads, and memory manipulation. 4, C18 (ISO/IEC 9899:2018) is the most recent standard and includes updates and clarifications to the language specification and the library. When writing C code, it's important to know which standard version is being used and to write code that is compatible with that standard, Many compilers support multiple standard versions, and it’s often possible to specify which version to use with a compiler flag or directive. Here are some advantaaes and disadvantaaes of usina the C.proarammina @ 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 coe hntps:www.geekstorgeeks orgic-programming-language-standardref=bp amt 1279128, 208 PM C Programming Language Stancard - GeeksforGeeks Advantages: 1. Efficiency: C is a fast and efficient language that can be used to create high- performance applications. 2. Portability: C programs can be compiled and run on a wide range of platforms and operating systems. 3. Low-level access: C provides low-level access to system resources, making it ideal for systems programming and developing operating systems. 4. Large user community: C has a large and active user community, which means there are many resources and libraries available for developers. 5. Widely used: C is a widely used language, and many modern programming languages are built on top of it. Disadvantages: 1, Steep learning curve: C can be difficult to learn, especially for beginners, due to its complex syntax and low-level access to system resources. 2. Lack of memory management: C does not provide automatic memory management, which can lead to memory leaks and other memory-related bugs if not handled properly. 3. No built-in support for object-oriented programming: C does not provide built-in support for object-oriented programming, making it more difficult to write object-oriented code compared to languages like Java or Python 4. No built-in support for concurrency: C does not provide built-in support for concurrency, making it more difficult to write multithreaded applications compared to languages like Java or Go. 5. Security vulnerabilities: C programs are prone to security vulnerabilities, such as buffer overflows, if not written carefully. Overall, C is a powerful language with many advantages, but it also requires a high degree of expertise to use effectively and has some potential drawbacks, especially for beginners or developers working on complex projects, Importance: 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 hntps:www.geekstorgeeks orgic-programming-language-standardref=bp aint 1279128, 208 PM C Programming Language Stancard - GeeksforGeeks MERN Full Stack Web Development 1. Choosing the right programming language: Knowing the advantages and disadvantages of C can help developers choose the right programming language for their projects. For example, if high performance is a priority, C may be a good choice, but if ease of use or built-in memory management is important, another language may be a better fit. 2. Writing efficient code: Understanding the efficiency advantages of C can help developers write more efficient and optimized code, which is especially important for systems programming and other performance-critical applications. 3. Avoiding common pitfalls: Understanding the potential disadvantages of C, such as memory management issues or security vulnerabilities, can help developers avoid common pitfalls and write safer, more secure code. 4. Collaboration and communication: Knowing the advantages and disadvantages of C can also help developers communicate and collaborate effectively with others on their team or in the wider programming community. The idea of this article is to introduce C standard. What to do when a C program produces different results in two different compilers? For example, consider the following simple C program. c 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 Cool Policy & Privacy Policy hntps:www.geekstorgeeks orgic-programming-language-standardref=bp ait 1291728,2.06 PM Programming Language Stancard - GesksforGesks The above program fails in GCC as the return type of main is void, but it compiles in Turbo C. How do we decide whether it is a legitimate C program or not? Consider the following program as another example. It produces different results in different compilers. c // C++ Program to illustrate the difference in different // compiler execution Hinclude int main() { int i= a5 printf ("Xd ¥d d\n", itt, ist, 4); return 0; 213 - using gt+ 4.2.1 on Linux.i686 1 23 - using SunStudio C++ 5.9 on Linux. i686 213 - using gtt 4.2.1 on SunOS. x86pc 1 2 3 - using SunStudio C++ 5.9 on SunOS. x86pc 1.2.3 - using g++ 4.2.1 on Sun0S.sundu 1 2.3 - using Sunstudio C++ 5.9 on Sun0S.sundu Source: Stackoverflow Which compiler is right? The answer to all such questions is C standard. In all such cases, we need to see what C standard says about such programs. What is C standard? The latest C standard is ISOMEC 9899:2018, also known as C17 as the final draft was published in 2018. Before C11, there was C99. The C11 final draft is available here. See this for a complete history of C standards. Can we know the behavior of all programs from C standard? 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 hntps:www.geekstorgeeks orgic-programming-language-standardref=bp am 1291728,2.06 PM Programming Language Stancard - GesksforGesks implementation. For example, in C the use of any automatic variable before it has been initialized yields undefined behavior and order of evaluations of subexpressions is unspecified. This specifically frees the compiler to do whatever is easiest or most efficient, should such a program be submitted. So what is the conclusion about above two examples? Let us consider the first example which is “void main() {)", the standard says following about prototype of main(). The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters: int main(void) { /* ... */ } or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared): int main(int argc, char *argv[]) { /* ... */ } or equivalent;1@) or in some other implementation-defined manner. So the return type void doesn't follow the standard, and it's something allowed by certain compilers. Let us talk about the second example. Note the following statement in C standard is listed under unspecified behavior. The order in which the function designator, arguments, and subexpressions within the arguments are evaluated in a function call (6.5.2.2). What to do with programs whose behavior is undefined or unspecified in standard? As a programmer, it is never a good idea to use programming constructs whose behavior is undefined or unspecified, such programs should always be discouraged. The output of such programs may change with the compiler 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 hntps:www.geekstorgeeks orgic-programming-language-standardref=bp sit 12131123, 208 PM C Hello World Program - GeeksforGeeks 36 5fG Offline Programs Trending Now Data Structures & Algorithms System Design C Hello World Program Foundational Courses Ds To begin with, the “Hello World” program is the first step towards learning any programming language and also one of the simplest programs you will learn. All one needs to do is display the message “Hello World” on the screen. Let's look at the program and try to understand the terminologies involved in it. C Program to Print “Hello World” The following C program displays “Hello World” in the output c // Simple © program to display "Hello World" // Header file for input output functions include // main function - // where the execution of program begins int main() { // prints hello world print#("Hello World"); return 0; Output Hello World Compiling the First C Program 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 hitps:nww-geekstorgeeks orgie-hello-wold-programv7reflbp Got it! amt 12/9129, 208 PM CCHeto Word Program -GeeksfoGeoks program. Here we have used a Windows-based GCC compiler to compile and run the program. To know more on how to set up the local GCC compiler or run using online ide refer to Setting C Development Environment. Step 1:This requires writing the “Hello World” program, in a text editor and saving the file with the extension .c, for example, we have stored the program in a C-type file HelloWorld. Wa haan —re (UF simue C propos ‘2 sop “elds hore 5 1 eae fr Sow tone fntons 1) toe the ezecition of progroe bens Inne i 1, grins tle sorts beset elie tea), Step 2: This includes opening CMD or command prompt line and navigating to the directory where the file HelloWorld.c is present. Here it is present in CAUsers\Chin\Sample. Step 3: To compile the code execute the following command: 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 hitps:nww-geekstorgeeks orgie-hello-wold-programv7reflbp aint 1279128, 208 PM C Hello World Program - GeeksforGeeks We use cookies to ensu 1 acknowledge th: ve \d understood our Cookie Policy & Priva alicy nitpssIww.geeksforgeeks.orgichello-nold-programi?reflbp 12131123, 208 PM C Hello World Program - GeeksforGeeks Line 1: // Simple © program to display “Hello World” 1. This is a single comment line. A comment is used to display additional information about the program. 2. A comment does not contain any programming logic as it is not read by the compiler. When a comment is encountered by a compiler, the compiler simply skips that line of code. 3. Any line beginning with 1’ without quotes OR in between /*...Y in Cis a comment. More on Comments in € Line 3: itinclude 1. In C, all lines that start with the pound (#) sign are called directives. These statements are processed by preprocessor program invoked by the compiler. 2. The #include directive tells the compiler to include a file and #include tells the compiler to include the header file for the Standard Input Output file which contains declarations of all the standard input/output library functions More on Preprocessors in C. Line 6: int main() 1. This line is used to declare a function named “main” which returns data of integer type. A function is a group of statements that are designed to perform a specific task. Execution of every C program begins with the main() 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 hitps:nww-geekstorgeeks orgie-hello-wold-programv7reflbp am 12/9129, 208 PM CCHeto Word Program -GeeksfoGeoks program must have a main() function and this is the function where the execution of the program begins. 2. { and }: The opening braces ‘{' indicates the beginning of the main function and the closing braces ‘}' indicates the ending of the main function. Everything between these two comprises the body of the main function and are called the blocks. More on main() function in C. Line 10: printf("Hello World"); 1. This line tells the compiler to display the message “Hello World” on the screen. This line is called a statement in C. Every statement is meant to perform some task. A semi-colon *; is used to end a statement. The semi- colon character at the end of the statement is used to indicate that the statement is ending there. 2. The printf() function is used to print a character stream of data on the stdout console. Everything within ” ” is displayed on the output device. More on Input/Output in C. Line 12: return 5 1. This is also a statement. This statement is used to return a value from a function and indicates the finishing of a function. This statement is basically used in functions to return the results of the operations performed by a function. 2. Indentation: As you can see the printf and the return statement have been indented or moved to the right side. This is done to make the code more readable. In a program as Hello World, it does not seem to hold much 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 hitps:nww-geekstorgeeks orgie-hello-wold-programv7reflbp sit 12191128, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks 3G GfG Offline Programs C CBasics CData Types COperators. Cin itand Output CControlFlow —C Funct Compiling a C Program: Behind the Scenes The compilation is the process of converting the source code of the C language into machine code. As C is a mid-level language, it needs a compiler to convert it into an executable code so that the program can be run on our machine. The C program goes through the following phases during compilation: Cc Executable How do we compile and run a C program? We first need a compiler and a code editor to compile and run a C Program The below example is of an Ubuntu machine with GCC compiler. @ We use cookies to ensure you have the best browsing experience on our website. By using our Got it! site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy hntps:nww-geekstorgooks orgicampling-«-c-progran-behind-he-scenes/eflop ans. 12131123, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks We first create a C program using an editor and save the file as filename.c $ vi filename.c We can write a simple hello world program and save it. Step 2: Compiling using GCC compiler We use the following command in the terminal for compiling our filename.c source file $ gcc filename.c -o filename We can pass many instructions to the GCC compiler to different tasks such as: + The option -Wall enables all compiler's warning messages. This option is recommended to generate better code. * The option -o is used to specify the output file name. If we do not use this option, then an output file with the name a.out is generated. If there are no errors in our C program, the executable file of the C program will be generated. Step 3: Executing the program 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 hntps:nww-geekstorgooks orgicampling-«-c-progran-behind-he-scenes/eflop ain 12191128, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks Cee se Poon atC een eec crs CE sre We use cookies to ensure you have the best browsing experience on our website. By using our & 1 acknowled \d understoo nitps:Iww.geeksforgeoks.orglcompling-¢-c-program-behind-the-scenes!?ref=lop 12191128, 205 PM Compiling @ © Program: Behind he Scenes - GeeksforGeeks EE SSeS BEB EaA SB B a § é A Ce te We use cookies to ensure you have the best browsing experience on our website. By using our nowledge that you have read and understood our Cookie Policy & Privacy Policy nitps:Iww.geeksforgeoks.orglcompling-¢-c-program-behind-the-scenes!?ref=lop 43 12131123, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks * Conditional compilation The preprocessed output is stored in the filename.i. Let's see what's inside filename.i: using $vi filename.i In the above output, the source file is filled with lots and lots of info, but in the end, our code is preserved * printf contains now a + b rather than add(a, b) that’s because macros have expanded. * Comments are stripped off. * #include is missing instead we see lots of code. So header files have been expanded and included in our source file. 2. Compiling The next step is to compile filename. and produce an; intermediate compiled output file filename.s. This file is in assembly-level instructions. Let's see through this file using $nano filename.s terminal command. 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 hntps:nww-geekstorgooks orgicampling-«-c-progran-behind-he-scenes/eflop 513 12191128, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks Cet GNU nano 4.8 Fulenane.s Gree Perera) ea) eee raat peer) era Ceram coe eee Tre RT Oey an gsc eerie Read 44 Lines Re We use cookies to ensure you have the best browsing experience on our website. By usin site, you acknowledge that you have read and understood our & nitps:Iww.geeksforgeoks.orglcompling-¢-c-program-behind-the-scenes!?ref=lop ena 12191128, 205 PM Compiling @ © Program: Behind the Scenes - GeeksforGeeks Corr ong Cores me erene caer Renee ean ee eerie ae 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 & nitps:Iww.geeksforgeoks.orglcompling-¢-c-program-behind-the-scenes!?ref=lop 73 12131123, 206 PM C Comments - GeeksforGeeks 36 GfGoffline Programs C CBasics CDataTypes COperators Cinputand Output CControl Flow CFunctie C Comments The comments i C are human-readable explanations or notes in the source code of a C program. A comment makes the program easier to read and understand. These are the statements that are not executed by the compiler or an interpreter. Itis considered to be a good practice to document our code using comments. When and Why to use Comments in C programming? 1. A person reading a large code will be bemused if comments are not provided about details of the program. 2. C Comments are a way to make a code more readable by providing more descriptions. 3. C Comments can include a description of an algorithm to make code understandable. 4. C Comments can be used to prevent the execution of some parts of the code. Types of comments in C In C there are two types of comments in C language: * Single-line comment * Multi-line comment hntps:www-geokstorgooks orgic-comments/reflop sno 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 Cool Got it! Policy & Privacy Policy 12131123, 206 PM C Comments - GeeksforGeeks Comments // Single line comment /* Multi-line comment * / 0G Types of Comments in C 1. Single-line Comment in C A single-line comment in C starts with (//) double forward slash. It extends till the end of the line and we don’t need to specify its end. 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 hntps:www-geokstorgooks orgic-comments/reflop 20 12131123, 206 PM C Comments - GeeksforGeeks // This is a single line comment Example 1: C Program to illustrate single-line comment c // © program to illustrate // use of single-line conment Hinclude int main(void) // This is a single-line comment print#("Welcome to GeeksforGeeks"); return @; Output: Welcome to GeeksforGeeks Comment at End of Code Line We can also create a comment that displays at the end of a line of code using a single-line comment. But generally, it's better to practice putting the comment before the line of code Example: c // C program to demonstrate commenting after line of code include 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 hntps:www-geokstorgooks orgic-comments/reflop 30 1273123, 208 PM (C-Comments - GecksforGeeks printf("Welcome to GeeksforGeeks"); // comment here return 0; Output Welcome to GeeksforGeeks 2. Multi-line Comment in C The Multi-line comment in C starts with a forward slash and asterisk (/*) and ends with an asterisk and forward slash ( */). Any text between /* and */ is treated as a comment and is ignored by the compiler. It can apply comments to multiple lines in the program. Syntax of Multi-Line C Comment /*Comment starts continues continues Comment ends*/ Example 2: C Program to illustrate the multi-line comment c /* C program to illustrate use of multi-line conment */ Winclude int main(void) 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 hntps:www-geokstorgooks orgic-comments/reflop 410 1219128, 206 PM “Tokens in C- GesksforGecks 3G GfG Offline Programs Read “Courses. ‘Practice ») (sobs We use cookies to ensu you have the best bro site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy sing experience on our website. By using our nitps:IMww.geeksforgeeks.orgtokensin-I?relop wn 1210129, 200 Pm Tokens in C- GeokstorGooks The keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. You cannot redefine keywords. However, you can specify the text to be substituted for keywords before compilation by using C preprocessor directives. C language supports 32 keywords which are given below: auto double int struct break else Jong switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while 2. C Token — Identifiers Identifiers are used as the general terminology for the naming of variables, functions, and arrays. These are user-defined names consisting of an arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as. a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special identifier called a statement label can be used in goto statements. 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 hntps:www.geekstorgeeks orgitokensin-?reflop aint 12131123, 206 PM “Tokens in C - GeeksforGecks Complete Data Analytics Program Rules for Naming Identifiers Certain rules should be followed while naming c identifiers which are as follows: + They must begin with a letter or underscore(_) + They must consist of only letters, digits, or underscore. No other special character is allowed. * It should not be a keyword + It must not contain white space. * It should be up to 31 characters long as only the first 31 characters are significant. Note: Identifiers are case-sensitive so names like variable and Variable will be treated as different. For example, * main: method name. * a: variable name. 3. C Token — Constants 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 hntps:www.geekstorgeeks orgitokensin-?reflop amt 12131123, 206 PM “Tokens in C - GeeksforGecks program once they are defined. Constants may belong to any of the data types. Examples of Constants in C const int c_var = 20; const int* const ptr = &_var; 4. C Token - Strings Strings are nothing but an array of characters ended with a null character (\0’) This null character indicates the end of the string. Strings are always enclosed in double quotes. Whereas, a character is enclosed in single quotes in C and CH. Examples of String char string[2@] = {‘g’, ’e’, ‘e’, ‘k’, ‘s’, °F, 0’, ‘r’, ‘B’, ’e’, fer, k, 657, “\}5 char string[20] = “geeksforgeeks”; char string [] = “geeksforgeeks”; 5. C Token — Special Symbols The following special symbols are used in C having some special meaning and thus, cannot be used for some other purpose. Some of these are listed below: * Brackets[]: Opening and closing brackets are used as array element references. These indicate single and multidimensional subscripts. + Parentheses(): These special symbols are used to indicate function calls and function parameters. * Braces{}: These opening and ending curly braces mark the start and end of a block of code containing more than one executable statement. * Comma (,): It is used to separate more than one statement like for separating parameters in function calls. 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 Cool Policy & Privacy Policy hntps:www.geekstorgeeks orgitokens-in-?reflop ann 1210129, 200 Pm Tokens in C- GeeksorGeks * Semicolon(;): It is known as a statement terminator. It indicates the end of one logical entity. That's why each individual statement must be ended with a semicolon. * Asterisk (*):| of variables. used to create a pointer variable and for the multiplication + Assignment operator(=): It is used to assign values and for logical operation validation * Pre-processor (#): The preprocessor is a macro processor that is used automatically by the compiler to transform your program before actual compilation. * Period (.): Used to access members of a structure or union. * Tilde(~): Used as a destructor to free some space from memory. 6. C Token - Operators Operators are symbols that trigger an action when applied to C variables and other objects. The data items on which operators act are called operands. Depending on the number of operands that an operator can act upon, operators can be classified as follows: + Unary Operators: Those operators that req e only a single operand to act upon are known as unary operators.For Example increment and decrement operators * Binary Operators: Those operators that require two operands to act upon are called binary operators. Binary operators can further are classified into: 1. Arithmetic operators 2. Relational Operators 3. Logical Operators 4, Assignment Operators 5, Bitwise Operator * Ternary Operator: The operator that requires three operands to act upon is called the ternary operator. Conditional Operator(?) is also called the ternary operator. 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 hntps:www.geekstorgeeks orgitokensin-?reflop sit 12131123, 206 PM Keywords in C- GesksforGeeks 36 GfGoffline Programs C CBasics CDataTypes COperators Cinputand Output CControl Flow CFunctie Keywords in C In C Programming language, there are many rules so to avoid different types of errors. One of such rule is not able to declare variable names with auto, long, etc. This is all because these are keywords. Let us check all keywords in C language. What are Keywords? Keywords are predefined or reserved words that have special meanings to the compiler. These are part of the syntax and cannot be used as identifiers in the program. A list of keywords in C or reserved words in the C programming language are mentioned below: auto | break | case | char | const | continue | default do double | else | enum | extern float for goto if int | long | register | return | short signed | sizeof | static struct | switch | typedef | union | unsigned | void volatile | while auto auto is the default storage class variable that is declared inside a function or a block. auto variables can only be accessed within the function/block they are declared. By default, auto variables have garbage values assigned to them. 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 Cool Policy & Privacy Policy hntps:iwww.geekstorgecks orgikeywordssinc!reflop 1s. 12131123, 206 PM Keywords in C- GesksforGeeks auto int num; Here num is the variable of the storage class auto and its type is int. Below is the C program to demonstrate the auto keyword: MERN Full Stack Web Development. c // © program to demonstrate // auto keyword tinclude int printvalue() { auto int a = 19; printf("xa", a); + // Driver code int main() { printvalue(); return @; 3 Output 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 2128 12131123,208 PM Keywords in C- GeekslorGeeks break and continue The break statement is used to terminate the innermost loop. It generally terminates a loop or a switch statement. The switch statement skips to the next iteration of the loop. Below is the C program to demonstrate break and continue in C: Cc // © program to show use // of break and continue include // Driver code int main() { for (int i= 1; i <= 105 i++) { af (4 { continue; } if (4 { break; } printf ("Xd ", i); } return 0; 2) 6) Output 1345 switch, case, and default The switch statement in C is used as an alternate to the i else ladder statement. For a single variable i.e, switch variable it allows us to execute 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 3125 12131123, 206 PM Keywords in C- GesksforGeeks switch(Expression) case ‘1': // operation 1 break; case:'2': // operation 2 break; default: // default statement to be executed Below is the C program to demonstrate the switch case statement: c 11 C program to demonstrate // suitch case statement Hinclude // Driver code int main() { int i= 45 switch (i) case 1 print#("Case 1\n") ;break; case 2 print#("Case 2\n") ;brea case 3 printf("Case 3\n");break; case 4 printf("Case 4\n");break; default print#("Default\n") sbreak; Output case 4 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 405 1218123, 206 PM Keywords in C- GeeksforGeeks Output case 4 Default char char keyword in C is used to declare a character variable in the C programming language. char x = Below is the C program to demonstrate the char keyword: Cc // © program to demonstrate 11 char keyword include // briver code int main() ¢ char c= ‘a’; print#("%c' return 0; os Output const The const keyword defines a variable who's value cannot be changed. const int num = 10; Below is the C program to demonstrate the const keyword: 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 5125 12131123, 206 PM Keywords in C- GesksforGeeks // © program to demonstrate // const keyword tinclude // Driver code int main() { const int 2 = 11; azat25 print#("¥d", a); return @; This code will produce an error because the integer a was defined as a constant and it’s value was later on changed. Output: error: assignment of read-only variable ‘a’ a-a+2; do The do statement is used to declare a do-while loop. A do-while loop is a loop that executes once, and then checks it's condition to see if it should continue through the loop. After the first iteration, it will continue to execute the code while the condition is true. Below is the C program to demonstrate a do-while loop. Cc // © program to demonstrate // do-while keyword include // Driver code int main() int i= 15 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 6125 12131123, 206 PM Keywords in C- GesksforGeeks } while(i <= 5); return 0; Output 12345 double and float The doubles and floats are datatypes used to declare decimal type variables. They are similar, but doubles have 15 decimal digits, and floats only have 7. Example: float marks = 97.5; double num; Below is the C program to demonstrate double float keyword: c // C program to demonstrate // double float keyword Hinclude // Driver code int main() { float £ = 0.3; double d = 10.67; printf("Float value: %f\n", f); printf("Double value: %f\n", d); return 0; Output 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 7125 12131123, 206 PM Keywords in C- GesksforGeeks if-else The if-else statement is used to make decisions, where if a condition is true, then it will execute a block of code; if it isn’t true (else), then it will execute a different block of code if(marks == 97) { // if marks are 97 then will execute this block of code y else { // else it will execute this block of code } Below is the C program to demonstrate an if-else statement: c // © program to demonstrate // if-else keyword include // vriver code int main() { int a = 10; if(a < 11) { printf ("A is less than 11"); , else t printf ("A is equal to or “greater than 11"); + return 0; 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 8125 12131123, 206 PM Keywords in C- GesksforGeeks A is less than 11 enum The enum keyword is used to declare an enum (short for enumeration). An enum is a user-defined datatype, which holds a list of user-defined integer constants. By default, the value of each constant is it's index (starting at zero), though this can be changed. You can declare an object of an enum and can set it's value to one of the constants you declared before. Here is an example of how an enum might be used c // An example progran to 1/ denonstrate working of 1) enun in C iHinclude // enum declaration: enum week(Mon, Tue, Wed, Thur, Fri, Sat, Sun); // Driver code aint main() ‘ J/object of the enum (week), called day enum week days day = Weds printf("xd", day); return @; Output extern The extern keyword is used to declare a variable or a function that has an evtornal linkane nutcide af the fila caclaratian 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 9125 12131123, 206 PM Keywords in C- GesksforGeeks c #include extern int a; int main(){ print#("Xd", a); return 0; for The “for” keyword is used to declare a for-loop. A for-loop is a loop that is specified to run a certain amount of times Below is the C program to demonstrate a for-loop: c // C program to demonstrate 11 for keyword Hinclude // Driver code int main() for (int i= 0; i <5; i++) t printf ("Xd ", i); } return 0; 3 Output 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 10125 12/9123, 208 PM Keywords in C- GeekslorGeeks goto The goto statement is used to transfer the control of the program to the given label. It is used to jump from anywhere to anywhere within a function Exampl goto label; // code label: Below is the C program to demonstrate the goto keyword: c // © program demonstrate 11 goto keyword Hinclude // Function to print numbers // from 1 to 18 void printNumbers() { int n= 45 label: printf ("Xd ", n); Af (n <= 18) goto label; // Driver code int main(){ printNunbers(); return 0; Output 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 115 1291128,208 PM Keywords in C- GeekslorGeeks int int keyword is used in a type declaration to give a variable an integer type. In C, the integer variable must have a range of at least -32768 to +32767. Example: int x = 105 Below is the C program to show the int keyword c // © program to demonstrate I/ int keyword Hinclude void sun() { int a= 10, b = 20; int sum; sun = a +b; print#("%d", sun); t // Driver code int main() ¢ sun()5 return 0; Output 30 short, long, signed, and unsigned Different data types also have different ranges up to which they can store numbers. These ranges may vary from compiler to compiler. Below is a list of ranges along with the memory requirement and format specifiers on the 32-bit 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 12105 12131123, 206 PM Keywords in C- GesksforGeeks Data Type Memory Range Format (bytes) Specifier short int 2 -32,768 to 32,767 hd unsigned short . 2 O to 65,535 %hu int unsigned int 4 0 to 4,294,967,295 %u long int -2,147,483,648 to 4 %ld 2,147,483,647 unsigned long 4 Oto 4,294,967,295 Solu int long Long int 8 -(2A63) to (2463)-1 lld unsigned long Oto . 8 Stu long int 18,446,744,073,709,551,615 signed char 1 -128 to 127 %c unsigned char 1 Oto 255 %e long double 16 3.4E-4932 to 1.1£+4932 LE Below is the C program to demonstrate the short, long, signed, and unsigned keywords: 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 19925 12131123, 206 PM Keywords in C- GesksforGeeks // © program to demonstrate // short, long, signed, // and unsigned keyword Hinclude // Driver code aint main() { // short integer short int a = 12345; // signed integer signed int b = -34; // unsigned integer unsigned int c = 12; // Lor 1 is used for J/ long int in c. long int d = 999981; printf(“Integer value with a short int data: %hd", a); print#("\ntnteger value with a signed int data: %d", b); printf("\nInteger value with an unsigned int data: Xu", c); printf("\nInteger value with a long int data: %ld", d); return 0; Output Integer value with a short int data: 12345 Integer value with a signed int data: -34 Integer value with an unsigned int data: 12 Integer value with a long int data: 99998 return The return statement returns a value to where the function was called Example: return x; 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 1425 12131123, 206 PM Keywords in C- GesksforGeeks c // C program to demonstrate // eturn keyword Hinclude int sum(int x, int y) ¢ int sun; sum =x +y5 return sun; 3 // Driver code int main() { int nunl = 10; int nun2 = 205 printf("Sum: %d", sum(numt, num2)); return @; Output sum: 30 sizeof sizeof is a keyword that gets the size of an expression, (variables, arrays, pointers, etc.) in bytes. Example: sizeof(char); sizeof(int); sizeof(float); in bytes. Below is the C program to demonstrate sizeof keyword: c 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 1525 12131123, 206 PM Keywords in C- GesksforGeeks // Driver code int main() ¢ int x = 105 print#("%d", sizeof(x)); return 0; } Output register Register variables tell the compil to store variables in the CPU register instead of memory. Frequently used variables are kept in the CPU registers for faster access. Example: register char c = 's'; static The static keyword is used to create static variables. A static variable is not limited by a scope and can be used throughout the program. It's value is preserved even after it's scope For Example: static int num; struct The struct keyword in C programming language is used to declare a structure. A structure is a list of variables, (they can be of different data types), which are grouped together under one data type. 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 1625 12131123, 206 PM Keywords in C- GesksforGeeks struct Geek { char name[S@]; int num; double var; oH Below is the C program for the struct keyword: Cc // C program to demonstrate // struct keyword Hinclude #include struct Books { char title[se]; char author(50); h // Driver code int main( ) ¢ // Declare Book1 of type Book struct Books book1; // book 1 specification strepy(booki.title, "C++ Programming"); strepy(booki.author, "Bjarne Stroustrup"); // Print book details printf("Book 1 title : %s\n", booki.title); print#("Book 1 author : s\n", book1 author: return 0; Output Book 1 title : C++ Programming Book 1 author : Bjarne Stroustrup 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 17105 1291128,208 PM Keywords in C- GeekslorGeeks typedef The typedef keyword in C programming language is used to define a data type with a new name in the program. typedef keyword is used to make our code more readable. For Example: typedef long num In this example we have changed the datatype name of “long” to “num”, union The union is a user-defined data type. All data members which are declared under the union keyword share the same memory location. Exampli union GeekforGeeks { int x; char $3 } obj3 Below is the C program for the union keyword c include union student { int age; char marks; dss // Driver code int main() { s.age = 155 s.marks 65 printf("age = %d", s.age); printf("\nmarks = Xd", s.marks); } 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 18125 1218123, 206 PM Keywords in C- GeeksforGeeks Output age = 56 marks = 56 void The void keyword means nothing i.e, NULL value. When the function return type is used as the void, the keyword void specifies that it has no return value. Exampl void fun() { // program volatile The volatile keyword is used to create volatile objects. Objects which are declared volatile are omitted from optimization as their values can be changed by code outside the scope of the current code at any point in time. For Example: const volatile marks = 98; marks are declared constant so they can't be changed by the program. But hardware can change it as they are volatile objects. Conclusion In this article, the points we learned about the keywords are mentioned below: + Keywords are Reserved words in C with certain meanings. * We can't use keywords as any element's name. * There are 32 keywords in C all having unique meanings. FAQs 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 hntps:iwww.geekstorgecks orgikeywordssinc!reflop 19925 12/9123, 208 PM Keywords in C- GeekslorGeeks Keywords in C are reserved words that have certain meanings and cannot be declare as any element's name. For example: for is used for declaring loop and it can't be declared as an element's name. 2. How many keywords are there in the C language? There are 32 keywords in the C language. 3. What is the sizeof keyword in C? Sizeof is a keyword that gets the size of an expression, (variables, arrays, pointers, etc.) in bytes. 4. What is the default keyword in C? The default keyword in C is used to specify the default case for the switch statement. 5. What is volatile in c used for? Volatile keywords in C are used for volatile objects. 6. Difference between keywords and identifiers. Keywords are reserved words that have some meaning whereas identifiers are the name-generated names for any variable, struct, class, object, or function in c Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - We use cookies to ensure you have the best browsing experience on our website. By using our site, ou acknowledge that you have read and understood our Coot Policy & Privacy Policy hntps:iwww.geekstorgecks orgikeywordssinc!reflop 20128

You might also like