Introduction To C programming - 1

         

                                Introduction to c programming



   The c character set

C language uses the uppercase letters A to Z, the lowercase letters a to z, the digits 0 to 9
   Special characters
   + - *  /  %  &  #  !  ?  ^  {  }  (   )  :  ;  ?  =  ,  <  >  (blank space)
Most versions of the language also allow certain other characters, such as @ and S, to be included with strings and comments.
            C program uses certain combinations of these characters, such as 
      \b = backspace
      \n = newline
      \t = Tab
These character combinations are known as escape sequences
Example of c pprogram… . 
Question- write a c program to print a hello word ?         
 Ans-  
    #include < studio.h>
     Main () 
   {
    Printf (“ Hello word “ ) ;
   }
This is very simple program  used  to print the message hello word  on the output screen. 
 1st line of program # is a compiler directive. 2nd line  uses a special word main, which denotes the starting point for execution of the program… All program start their exaction from main. Printf is a only executable statement in above program. This is use to display any message on the screen. 
  Any message written within double quotes of the printf statement is displayed as it is. But one ma note the absence of \n in the output, although this was also included within the double quotes. \n is act ally a special character (known as escape sequence), which corresponds to newline character. Inclusion of \n in double quotes means that cursor should be shifted to start of next line. If you see carefully the output

screen above, the cursor position (shown as =) can be noticed at the start of next line. Had this statement

been written as
printf("Hello \n word ) ;
The output screen would have been different. And looked as 
    Hello
    Word
It may be noted that C programming gets shifted to next line now. Reason for that is the changed position of \n in the modified printf statement. But the cursor remains in the same line now just after the last alphabet  of the displayed message as there is no new line character at the end of the message. This will affected the next output when you rexecute the same program. 
  The semi colon (;) is a must after completion of every statement (end of any line does not necessarily mean completion of a statement). In the above example, semi colon has been put after printf statement, denoting its completion. It is worth noting that all instructions related to C program have been written in lowercase. Remember C is case-sensitive language and thus, any lowercase character cannot be used as uppercase or vice versa. Most of the instructions of C are written in lowercase. 

IDENTIFIERS AND KEYWORDS


Identifiers are names that are given to various program elements, such as variables, functions and arrays. Identi- fiers consist of letters and digits, in any order, except that the first character must be a letter. Both upper- and lowercase letters are permitted, though common usage favors the use of lowercase letters for most types of identifiers. Upper- and lowercase letters are not interchangeable (i.e., an uppercase letter is not equivalent to the corresponding lowercase letter.) The underscore character (_) can also be included, and is considered to be a letter. An underscore is often used in the middle of an identifier. An identifier may also begin with an underscore, though this is rarely done in practice.    
   The standard keyword are 
There are certain reserved words, called keywords, that have standard, predefined meanings in C. These keywords can be used only for their intended purpose; they cannot be used as programmer-defined identifiers. The standard keywords are
1]auto
 2] extern
3] static
3] break
4] Floatn 
5] for
6] case
7] switch
8] char
9] goto
10] typedef
11] const
12] if
13] union
14] continue
15] int
16] default
17] long
18] unsigned
19] do
20] register
21] void
22] double
23] return
24] volatile
25] else
26] short
27] while
28] enum
29] signed
30] sizeof

 also include some or all of the following keywords.
1]ada
2] far
3] near
4] asm
5] fortran
6] pascal
7] entry
8] huge

कोई टिप्पणी नहीं:

एक टिप्पणी भेजें

Data Types in C (part 2)

        Data Types in C.......             Today, we will continue our discussion on integer data type. Our outline for today...