Basic things in C Programming Language (Header files, main (), printf(), scanf(), Variables)

Header files

     The files that are specified in the include section is called as header file. These are precompiled files that has some functions defined in them. We can call those functions in our program by supplying parameters Header file is given an extension .h. C Source file is given an extension .c

main ()
  This is the entry point of a program. When a file is executed, the start point is the main function. From main function the flow goes as per the programmers instructions. There may or may not be other functions written by user in a program. Main function is compulsory for any c program.

printf()

printf() statement is used to output the expression values and messages on to the output screen. General structure of printf() is printf(“ message placeholder”, variables);

Ex program:
#include <stdio.h>
// program prints a number of type int
      int main()
      {
         int number = 10;
         printf (“The Number is %d”, number);
      }

scanf()

scanf (); //used to take input from console(user).
 scanf(“%d”, &a);

 Remember to use & symbol along with integer/floating variable. Does not use at the time of reading character/string type data.

Some of the format specifier %c for The character. %d for The integer format specifier. %f for The floating-point format specifier. %s for The string format specifier.

Variables

Variables are data that will keep on changing.

Declaration

Data type variable name;
int a;

Initialization

varname=value;
a=10;

Basic things in C Programming Language (Header files, main (), printf(), scanf(), Variables) Basic things in C Programming Language (Header files, main (), printf(), scanf(), Variables) Reviewed by Unknown on 08:03 Rating: 5

No comments:

Powered by Blogger.