Skip to main content

Basics of C with example

                          C   language                           

C is a procedural programming language. It was initially developed by Dennis Ritchie and Ken Thompson in the year 1972 at AT and T bell lab of USA . 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 clean style, these features make C language suitable for system programmings like an operating system or compiler development. It is mainly used to convert high level code into low level language code and vice versa.

High level language code includes.........     A,B,C......
                                                                    0,1,2,3......
                                                                    &,-,+,*.......

Low level language code includes........       0 & 1
                                                                     (0--off/false/low)
                                                                     (1--on/true/high)

Basic rules for C programming language 

  •  Includes all required header files.
  •  Includes main function.
  •  Includes required variables.
  •  Includes all required statements.
  •  Closes the main Function.
Example...A program to print hello in C language.
Example of C program

This is very basic program which has one header file and main function only. When we press ctrl + F9 , this does not run because it has only one basic header file. To run our program we will learn further.

  • Header File
It is predefined program which contains ready made functions.

  • Function
It is the smallest individual sub program which performs specific task.

  • Main Function
It is a special function which is developed by user and invoked by a C compiler . It is also known as start point of C program.

  • printf
It is use to print messages as well as variables values . 
SYNTAX
printf("message");
ex.  printf("Hello..");
printf("conversion specifier",variable);
ex.   printf("%d",a);

  • clrscr()

It is use to clear the output screen at the run time .Its header file name is conio.h(console input output header file).
  • getch()
It is use to input a character through keyboard at the run time but it is not visible.

example...Program to print hello using all these which we have discussed above.
Example in C to print hello
for compilation press...alt+F9
to run the program press....ctrl+F9
Output ↓








Comments

Popular posts from this blog

Datatypes

                       DATATYPES IN C What is datatype ??? C data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before to use in a program . Following are the examples of some very common data types used in C: char:  The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers. int:  As the name suggests, an int variable is used to store an integer. float:  It is used to store decimal numbers (numbers with floating point value) with single precision. double:  It is used to store decimal numbers (numbers with floating point value) with double precision. DATA TYPE MEMORY (BYTES) RANGE FORMAT SPECIFIER short int 2 -32,768 to 32,767 %hd unsigned short int 2 0 to 65,535 %hu unsigned int 4 0 to 4,294,967,295 %u int 4 -...

Difference in C and C++ language

  Difference between C and C++ Language.. C                            C is procedure oriented programming (POP). In C programs are divided into small parts known as functions. Encapsulation,abstraction,Inheritance and polymorphism are not supported in C. Inline functions and virtual functions are not available in C. Function overloading and operator overloading are not possible in C. C uses scanf() and printf() functions for input/output. C uses malloc() and free() functions for dynamic memory allocation and dealloaction. C does not support exception handling. Filename extension is . Follows top down approach in program design. Example...1.Program to add two numbers. #include <stdio.h> #include<conio.h> void main() {    int a,b,c;   printf("Enter two numbers :");   scanf("%d,%d",&a,&b);   c=a+b;   printf("Addition is : %d",c...