C Programming

1-Intro to C Programming Language

C Programming Lessons, Learn C Programming, Introduction to C Language, How to Program with C

C language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories.

C is a powerful general-purpose programming language. It’s being used to developing operating systems, databases, compilers, and so on.

Why Should We Learn C ?

Easy to learn

Can be used for low-level tasks called machine language

A structural language

Can be compiled on different computer platforms

Getting Set Up – Finding a C Compiler

A compiler is the first thing you will need before you start programming in C. What is a compiler, you ask? A compiler turns the program that you write into an “executable” that your computer can actually understand and run.

For Windows users; Code::Blocks

For Linux users; gcc

For Mac users; XCode

Also some online compilers can be used for simple examples, such;

https://www.programiz.com/c-programming/online-compiler/

https://replit.com/languages/c

Let’s Start with First Simple Code

First, we need to create a blank Project

#include <stdio.h>

int main() 
{
   /* my first program in C */
   printf("Hello, World! \n");
   
   return 0;
}

then type the code in created “New File” when you click “Build & Run” button, output of the IDE will be like given below.

Let’s take a closer look at this simple code we wrote;

  • Lines starting with the # sign are processed by the preprocessor before the program is compiled.
  • stdio.h is the standard input output header file. By including header files, you can gain access to many different functions. The printf function is included in stdio.h.
  • int main() is part of every C program. The parentheses after the word main indicate that it is one of the program building blocks called functions.
  • C programs can contain more than one function, but one of them must be main. In C, every program starts by running the main function. { curly braces must be written at the beginning and end of each function.
  • The printf function is the standard C way of displaying output on the screen.
  • The \n escape sequence means a new line and causes the cursor to move to a new line.

*Hint!

Since printf perceives the \ sign as an escape character, it should be used as \\ if you want to print the \ sign on screen, and when you want to print , it should be used as \”.

Examples:

printf(“Welcome to “);

printf(“C Language!\n);

Output is:

printf(“Welcome to\n C Language\n”);

Output is:

Leave a Reply

Your email address will not be published. Required fields are marked *