Introduction C

Introduction to c

  • C is programming language that has been developed and design by Dennis Ritchie in 1970’s at AT & T’s Bell labroatories of USA.
  • C is written under UNIX operating system.
  • C is popular because it is Reliable , simplem easy to use and portable.
  • Programs written in C language are fast and very efficient Than its predecessors.

General structure of a C programming

Comments
Pre-processor directives
Global varibale declarations
Function defining statements
{
local varibale and function declarations
Executable statements
}
Function1 ()
{
}
Function2 (){
}

Important:

  • C is case senstive language , in which varibales defined with lowercase and uppercase letters are different.
  • Every C program consists of one or more functions, one of which must be main (). The program always starts executing from the main() function.
  1. Comments : Comments is used to tell what program you are actually writing , which is necessary to increase the readability of the program.
  2. Pre-processor : Pre-processor include macros such as #include, #define to include header files.
  3. Global varibale: Global varibale which is visible throughout the program.
  4. Function defining statements which is actually main program, from where the program actually starts executing.
  5. Local varibales and function declarations: It include those varibales that are local means the have scope only in this function, In this part we can also call and declare functions.
  6. Executable statements: Executable statements that are converted into machine language and executed in a given order.
  7. In the last section there may be one or more functions defined, which is already called from within the main () or other function.

First Simple hello world program Of C

/*Program to Print the hello world */
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“\n hello world”);
}
Output: hello world
Program to calculate sum and product of Two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a , b, sum , prod;printf(“enter two number”);
scanf(“%d%d”,&a,&b);
sum=a+b;
prod=a*b;
printf(“sum and product of two numbers is : %d and %d”,sum,prod);
getch();
}