Don’t stop when you’re tired. STOP when you are DONE.
--Your friends at LectureNotes

Note for C Language - C By Aman Kumar

  • C Language - C
  • Note
  • 1 Offline Downloads
  • Uploaded 9 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

7. You will be able to see "Hello World" printed on the screen Structure of c programm :C Hello World Example 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() { /* my first program in C */ printf("Hello, World! \n"); return 0; } Let us look various parts of the above program: • 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 ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. • The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen. • The next line return 0; terminates main()function and returns

Text from page-3

the value 0. Print Function : The C library function int printf() sends formatted output to stdout. Declaration Following is the declaration for printf() function. int printf(); Comments in C language: In programming, comments are used to described the workintg of the code. compiler ignore the line which are written in a comment. There are two types of comment in 'C'1.Single line Comment: // this is used for to declare single line comment. 2.Multi line Comment: /*This type of comment is used to declare multiple line of comment*/ Class 2: Introduction to C block of statement: C has three types of statement1. Assignment ( = ) 2. Selection (Branching): • if(expression) • else • switch 3. Iteration (Looping)

Text from page-4

• While • for • do Blocks: These statement are grouped in to blocks, a blocks is identified by curly brackets. there are two types od Blocks: 1. Statement blocks: if(i==j) { printf("|n martin \n"); } 2.Function Blocks: int add(int a,int b) { int c; c=a+b; return c; } Displaying Data: Displaying data means graph representation of any program:

Text from page-5

Flowchart Symbols For most flowcharts, these five basic symbols are all you will need. Class 3: Data Type: C has a concept of 'data types' which are used to define a variable before its use. The definition of a variable will assign storage for the variable and define the type of data that will be held in the location. The value of a variable can be changed any time. C has the following basic built-in datatypes. int : Following table gives you details about standard integer types with its storage sizes and value ranges: Type Storage size Value range char 1 byte -128 to 127 or 0 to 255 unsigned char 1 byte 0 to 255

Lecture Notes