0%
Loading ...

C Language Basics

This category contains tutorials related to C language basics.

Basic Syntax of C program

In this tutorial, we will learn about the Basic Syntax of C program. Here will write our the first program in C programming. Let’s write a program in C. Example Program: #include <stdio.h> int main() { //Our first program printf(“Hello, World! \n”); return 0; } Output: Hello, World! Elements of Example Program: You can see the basic syntax of a C program. Now here we will learn about all the elements in our program and will understand what they do in this C program. Pre-processor Header file main() Function printf() Comments Pre-processor: You can see we have written #include in the first line of the program. This #include is known as Pre-processor. These pre-processors are used to set up the environment for the c program. In our program pre-processor informing compiler to include stdio.h header file in our program. Header file: The c has a lot of inbuilt files which contain a lot of useful functions. These files are known as header files. As in the above program, you can see we have used printf() function to show Hello World on the screen. Can you guess from where we got this function? The answer is very simple we got this function from the stdio.h header file. main() Functions: The main function is something which would be part of all the C programs. It is important to note we right all our code inside this main function. As you can see we have written int before the main. Here int(data type) is working as the return type of our main function(we will discuss return type in our functions tutorial). After the main function, we have written starting bracket and some code inside {} brackets. The code inside {} of the main function is known as the body of the main function.print: printf(): On the fourth line in the example program, you can see have written something like printf(“Hello, World! \n”);. Here printf() is a function which is part of stdio.h header file and this printf() function is used to show output on screen here in our program output will be Hello, World!. Comments: On the third line in the example program, you can see have written something like //Our first program. When we write a single line statement with // in starting. It is known as comments in the C program and comments do not perform any task in the program. Comments are just to help programmers to remind about functions and variables etc. Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Basic Syntax of C program Read More »

Environment setup for C Programming

In this tutorial, we will learn about Environment setup for C Programming. To run c programs we need two things in our machine first one is TextEditor and the second one is c compiler. We will write code in the TextEditor and our second software the compiler will help us to compile our written program into machine-readable form(in binary language). Environment setup for C Programming(In windows): Download a Text Editor Notepad++ or Vim or any other. Download C Compiler TDM-GCC Install TextEditor and Compiler Environment setup for C Programming(In MAC): Download and install Xcode on an Apple Mac from App Store Install GCC/LLVM compiler on from Xcode->Preferences– > Downloads– > choose “Command line tools” > Click “Install” button: To check you have successfully installed it C compiler write following command in terminal: $ gcc –version Environment setup for C Programming(In Linux): Write following command in terminal to install C compiler: sudo apt install GCC Type ‘y’ when you get a message in terminal like this “Do you want to continue?” and then press Enter. After successful compilation write gcc –version to check the current installed version of C compiler, IDE for C Programming: There are various Integrated Development Environment software available for all operating systems(windows, Linus, Mac). You can also download IDE and it will automatically download compiler. Here is List of some popular IDE software: Eclipse Dev C++ CodeLite NetBeans 8 Code::Blocks Sublime Text Visual Studio Code Please keep continue with the next tutorial. In the next tutorial, we will write our first program in C language. Click here to open the next tutorial. Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Environment setup for C Programming Read More »

Introduction to C

In this tutorial, we will learn an introduction to C programming language. C is a general-purpose computer programming language. It is developed by Dennis M. Ritchie in the year 1972 at the Bell Telephone Laboratories. C language is really useful to develop Operating Systems, Network Drivers, Language Interpreters, Language Compilers etc. History of C: Here you can see the different versions of C languages with the publication date. VERSION STANDARD PUBLICATION DATE K&R n/a 1978-02-22 C89 ANSI X3.159-1989 1989-12-14 C90 ISO/IEC 9899:1990 1990-12-20 C95 ISO/IEC 9899/AMD1:1995 1995-03-30 C99 ISO/IEC 9899:1999 1999-12-16 C11 ISO/IEC 9899:2011 2011-12-15 Here K&R representing to Brian Kernighan and Dennis Ritchie Example Program: Here is an example program. The basic motive of this program is to show the syntax of a C program. #include <stdio.h> int main() { printf(“Hello, World! \n”); return 0; } Applications of C Programming language: – C programming language can be used to develop various types of software. Please check out the following list of application of C programming language. To develop operating systems. It can be used to create language compilers. Network devices can be programmed using C language. GUI application software can be designed using C language. It is one of the popular language used in embedded systems. Used to create Database Management Systems such as MySQL. We can use C programming language to develop web browsers for e.g. chromium. This was just an introduction tutorial to C programming language. In the next tutorial, we will learn how to set up the environment on our computer to run c programs. Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Introduction to C Read More »

Scroll to Top
×