Friday, 31 May 2019

How to write a c program?

After writing any program first we know about what is program? And
What are the essential rules for writing a program in c?

Program-: The collection or group of instructions & informations is called a program.

These are the some important rules for the writing a program in c--

1. Never use capital letters.
2. Use ; in last of statement.
3. Use variable to define parameters
   a, x, y, p, q.... ✔
   ax, bx, xy...... ✔
   x1, x2, x5...... ✔
   3x, 6x, 2x......❌
4. Header file should be included.
     Two header files must be included
First-
         #include<stdio.h>
    Stdio means standard input/output.
   Where .h is the extension of header file.
    The work of this header file is --
    In this files Printf() ; and scanf(); are         executed.
Second-
              #include<conio.h>
      Conio means console input/output.
       The work of this header file is--
      In this file getch() ; and clrscr();         are executed.
. The purpose of getch(); is to hold the output on the console.
. The purpose of clrscr(); is to clear all the trash data on the console.

5. If we take integer type value then we have to use
         Int
        0-9
        %d
     If we take float type value then we have to use
          float
           0.1,.57,.886
          %f
If we take charecter type value then we have to use
           Char
            a-z
             %s

6. Program will start from main().
7. After main(); start the program with curly braces {_}.
8.

Let's take an example of c program---
      #include<stdio.h>    
      #include<conio.h>
        main()
          {
             printf("my name is A.");
             getch();
           }
Output of this program is
   my name is A.
 

Note-:#<include> is pre processor command. This statement tells the pre- processors to include the information contained in the file stdio.h before it is past for the compilation.

main() - main is a special function name. Every c program has main function somewhere in the program. This function will be executed first when the program is run.
           &- is used for the address of the          value where stored.
            If you are writing a c program in turbo c software then
    To compile your program press Alt+f9
      To run the program press Ctrl+f9.

1 comment:

  1. Thanks...I taught very easily how to make a c program....

    ReplyDelete