Open In App

C File Format | .c Extention

Last Updated : 07 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

What is a C program file?

C file extension contains the C program files. C is a high-level, procedural, general-purpose programming language that can create games, web applications, system programming, computer software, and more. Programs written in the C programming language are built on top of C source code files identified by the .c extension. It is a powerful and adaptable language initially created for UNIX operating system programming. Ken Thompson and Dennis Ritchie worked at Bell Labs between 1972 and 1973 to develop the C programming language.

Example of C Program File

C




#include <stdio.h>
 
int main() {
    // Declare and initialize two numbers
    double num1 = 5.5;
    double num2 = 10.3;
 
    // Calculate the sum of the two numbers
    double sum = num1 + num2;
 
    // Display the result
    printf("The sum of %.2lf and %.2lf is: %.2lf\n", num1, num2, sum);
 
    // Return 0 to indicate successful program execution
    return 0;
}


Output:

The sum of 5.5 and 10.3 is 15.8

Features of the C language

  • C language is the procedural language, so it follows the top-down approach.
  • It is a mid-level language which means it combines the features of the high-level language and low-level language.
  • It allows the direct manipulation of the hardware and memory.
  • It is statically typed, which means that the data types of variables must be declared before they are used.

Applications of C language

  • Most of the operating systems are written in the C language.
  • It is the developers’ first choice when it comes to scripting the drivers and embedded system.
  • It can be used to develop compilers such as clang-c, Apple-c, and MINGW all are written in C.

How to use the C Program File

Here is a simplified example of a C program file where we can see the code explanation of the program file.

C




#include <stdio.h>
 
int main() {
 
    // code
    printf("GFG!");
    return 0;
}


Explanation

  • The inclusion of the Header files marks the beginning of the C program. A header file is any file ending in .h that contains C function declarations and macro definitions that are shared by several source files.
  • In a C program, the declaration of the main() function comes next. This is the start of a C program, and the program usually runs from the first line of the main().
  • The instructions provided to the compiler are called statements. A semicolon (;) always marks the end of a statement in C.
  • The last section of any C function is the return statement. A function’s return values are specified in the return statement. The return value and return statement are determined by the return type of the function.

Advantages of the C language

  • C combines features from both high-level and low-level languages. It supports both low-level programming, such as scripting for drivers and kernels, and high-level programming, such as scripting for software applications.
  • It is a structured programming language that allows a complex program to be divided into smaller programs called functions. It also enables the free flow of data between these functions.
  • It has a rich library that provides several built-in functions.
  • It also offers a dynamic memory allocation.
  • It is case-sensitive which means lowercase and uppercase letters are treated differently.

Disadvantages of the C language

  • C language does not support object-oriented programming languages (OOPs).
  • There is no support for the expectation handling in the c language.
  • The C programming language does not detect errors or bugs after each line of code, as other programming languages do.
  • It does not support any type of garbage collection, the developer needs to take care of memory management.

Conclusion

C program files, denoted by the .c extension, serve as containers for C programming language code, enabling the creation of diverse applications. Developed by Ken Thompson and Dennis Ritchie for UNIX, C is a high-level, procedural language known for its versatility and direct hardware access. C stands as a foundational language valued for its balance between high and low-level programming.

FAQs

Q1. What is type of file in C?

Ans: There are two types of the files one is text file to be read by humans and another is binary file used by computer.

Q2. How many keywords in the C?

Ans: There are total of 32 keywords in c language.

Q3. Which is faster C or C++?

Ans: Both the language will have same execution speed.

Q4. Which is faster C or Python?

Ans: C is faster language then the python because C is compiled language and Python is interperated language.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads