computer programming. topic: structure of c programming
DESCRIPTION
LECTURE # 03 BY:HIRA FARMANTRANSCRIPT
COMPUTER PROGRAMMING
Topic:
STRUCTURE OF C PROGRAMMING
LECTURE # 03
BY:HIRA FARMAN
STRUCTURE OF C PROGRAMMING
1. C's character set 2. C's keywords 3. Pre-processor commands4. Functions5. Comments6. Layout Of C Program.
STRUCTURE OF C PROGRAMMINGC CHRACTER SETS:• C does not use, nor requires the use of, every character
found on a modern computer keyboard. The only characters required by the C Programming Language are as follows:
• A - Z• a -z• 0 - 9• space . , : ; ' $ "• # % & ! _ {} [] () $$$$ &&&& |• + - / * =
STRUCTURE OF C PROGRAMMING
• Keywords• C makes use of only 32 keywords which
combine with the formal syntax to the form the C programming language.
STRUCTURE OF C PROGRAMMING
• Preprocessor Commands : These commands tells the compiler to do preprocessing before doing actual compilation.
• 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.
STRUCTURE OF C PROGRAMMING
• Functions: are main building blocks of any C Program.
• Every C Program will have one or more functions and there is one mandatory function which is called main() function.
• This function is prefixed with keyword int which means this function returns an integer value when it exits. This integer value is returned using return statement or sometimes we use prefixed keyword void.
STRUCTURE OF C PROGRAMMING
• Comments: are used to give additional useful information inside a C Program. All the comments will be put inside /*...*/ as given in the example above. A comment can span through multiple lines.
STRUCTURE OF C PROGRAMMING• main() is a function.• In a c program there can be multiple
functions. To begin with, we would concentrate on only those programs which have only one function. The name of this function has to be main(),it cannot be anything else.
• All statements that belongs to main() are enclosed within a pair of braces{} as shown below.
STRUCTURE OF C-PROGRAMvoid main()
{Statement1;Statement2;Statement3;
.
.
.}
Header Files:•The files that are specified in the include section is called header files.•These are precompiled files that has some functions define in them.•Header file is given an extention.h•C source file is given an extention.c
1-Simple C-Program
#include <stdio.h>#include<conio.h> void main() { /* My first program */ printf("Hello, World! \n");}
2-Simple C-Program#include <stdio.h>#include<conio.h> void main() { /* My 2nd program */ printf("Hello, World! \n");printf(“Hello!\n”);printf(“I am student!\n”);printf(“c is my favorite language!\n”);}
Function getch()first getch() is a function already defined in the <stdio.h>
It’s C library function.
getch() the name of the function is made up of two things "get" which simply mean get and "ch" which mean character...so in simple terms..it mean "get a character from keyboard buffer
if you didn't use the getch(), you won't able to see the result of the program..
It stops the console screen.
Use Of Function getch()
Your program will finish running and terminate itself after computing and displaying. But you won't be able to see the output. For that, just to stop there, so that you can see the output, we use getch().
Use Of Function Clrscr()
• Another C library function.• Clears the contents present in the screen.
NOTE:
• C is a case sensitive programming language. • C has a free-form line structure. End of each C
statement must be marked with a semicolon.• White Spaces (i-e tab space and space bar )
are ignored.
Borland Turbo C(The integrated development environment)
Turbo C is an Integrated Development Environment (IDE) and compiler for the C programming language from Borland. First introduced in 1987, it was noted for its integrated development environment, small size, fast compile speed, comprehensive manuals and low price.
•If you are beginner you would be better off using a simple compiler Turbo C or Turbo c++.Once you have mastered the language elements you can then switch over to more sophisticated compilers like Visual C++.
• The IDE provides an almost ideal environment for learning C.
Integrated Development Environment(IDE)
• SCREEN SHORTS
SUMMARY # 03:
• Write all 32 keywords used in C programming?• Summarized Today's lecture and write 1o
points as your choice.