Posts

Showing posts from August, 2015

C program print integer

#C program print integer C programming code- #include <stdio.h>                 //header file int main () {     int a ;                     //variable declaration    printf ( "Enter an integer \n " ) ;         //print double cote statement    scanf ( "%d" , & a ) ;             //read the integer value enter by user    printf ( "Integer that you have entered is %d \n " , a ) ;//print statement as well        value of“a”    return 0 ; } Data Type integer In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storag...

Basic structure of C program

Basic structure of C program: Documentation section Link Section Definition Section Global declaration section Function prototype declaration section Main function User defined function definition section C Hello world program : A C program basically consists of the following parts:   Preprocessor Commands   Functions  Variables Statements & Expressions Comments Let us look at a simple code that would print the words "Hello World": #include <stdio.h> int main() {      /* first program in C */       printf ( "Hello, World! \n" );      return 0; } The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. The next line int main() is the main function where program execution begins. The next line /*...*/ will be ...

C basic syntax

Image
C basic syntax Tokens in C A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens: printf("Hello, World! \n"); The individual tokens are: printf ( "Hello, World! \n" ) ; Semicolons ; In C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity. For example, following are two different statements: printf("Hello, World! \n"); return 0; Comments: Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminates with the characters */ as shown below: /* my first program in C */ You cannot have comments within comments and they do not occur within a string or character literals. Identifiers: A C identifier is a name used ...