Programming With C Language


First Program In C

C is a high-level and general-purpose programming language that is ideal for developing firmware or portable applications. Originally intended for writing system software, C was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970s.
C language is a case sensitive language.

To do programming in C first we should install a C editor such as Turbo C,C free,codeblocks etc. In here i am using codeblocks as my editor. But also we can do coding in notepad also. 

After installation now we are going to write our first program.

open codeblocks get a new empty file and write the code below.

#include<stdio.h>← header file
int main()← function
  ↑
return type
{
    printf("Hello World \n");
    return 0;                     ↑
}                              line break

Save this source code as HelloWorld.c(any name you like with .c extension).
To convert this source code in to machine code,compile the code.
                Build→Build
To execute the program and to see the output , run the program.
                Build→Run

If we are coding using the notepad we don't need to install the C compiler.
we have to save our notepad file with .c extension. Then we can run the program using the command prompt.
you should call the prompt where you created the c file otherwise you should give the path in the prompt. To call the command prompt you can simply press ctrl + shift + right
Then you should write this command exactly as below in the prompt.

gcc HelloWorld.c -o runthis.exe
            ↑
    (file name)
then press enter and write the command  below in the next line

runthis.exe
Then the output will be displayed in the next line.

This is how we can run a program using notepad.




Comments

Popular posts from this blog

Programming with Java

C- Control Structures

C - Functions