C

Fundamental concept of Problem solving
Introduction
Problem solving strategies
Program design & implementation
Introduction to C
Introduction to C
How to open C program code window
Description of C code window
Editing File
Saving and Running a program
The components of C language
Structure of C Program
A sample of C language program
C character set and keywords
C character set and keywords
The C character set
Identifiers
Key words
Data Types
Data Types
Primary Data Type
Secondary Data Type
Variables
Introduction
Rules for constructing variables names
Variable declaration
Assigning values to variables
Scope of variables: Local & Global
Constants
Introduction
Character constants
Integer constants
Real constants
Logical & String constants
C instruction set
Introduction
Type Declaration & Input/Output Instructions
Arithmetic Instructions
Control Instructions
Operators
Introduction
Arithmetic operators
Relational operators
Logical operators
Increment & Decrement operators
Bitwise operators
Conditional & ternary operators
The comma operators
Size of operator
Assignment operator
Type modifier
Expressions
Evaluation of expression
Automatic type conversion
Basic Input/Output
Introduction
Console I/O function
Disc & Port I/O function
Control Structures
Sequence control statements
Decision control & conditional statements
Case control statements
Repitition & loop control statements
Some more statements
Array and String
Introduction of Array
Array Declaration
Array Initialization
Two Dimensional Array
Multi Dimensional Array
String
Function and Recursion
Function Definition
Function Declaration
Function Call
Recursion
Pointers
Introduction
Pointer expression
Pointer & functions
Pointer & Array
Multi Dimensional Arrays & Pointer
Arrays of Pointer
Use of Pointer & functions
Structures
Introduction
Giving values to member
Structure Initialization
Comparison of structure variables
Arrays of structures
Arrays within structures
Structures within structures
Passing structure to function
Union
Introduction
Accessing a union member
Initialization of Union variable
Uses of Union
Dynamic Data Structure
Linked list
Stack
Queue
Data File Handling through C
Introduction
File operation
Opening & closing a data file
Creating a data file
Processing a data file
Unformatted data file
C Preprocessor & Macro
Introduction
Macro substitution directives
File inclusion
Compiler control directive
Command line parameter of C
Command line parameter
Header file
Header file
Use of library functions
Some Useful library functions

Basic Input/Output


Console I/O function

Console I/O refers to the operation that occur at the keyboard and the screen of your computer.
 
Console I/O function can also be classified in two parts:
 
1. Formatted console I/O:
 
Formatted I/O function accepts or present in a particular format. The example of formatted console I/O function is printf( ) and scanf( ).
 
printf
 
It is highly desirable that the output are presented in such a way that they are understandable and are in a form easy to use.
 
The printf() statement provides certain features through which the screen output is effectively controlled.
The general form of printf() function is:
 
printf("Control String ",arg1,arg2....);
 
Control string may contain:
 
1. character that are simply printed as they are.
 
2. Conversion specification that begin with a sign.
 
3. Escape sequence that begin with \ sign.
 
Given below is a list of conversion charcter that can be used with printf() function:
 
 
scanf
 
scanf allows formatted reading of data from the keyboard. Like printf it has a control string, followed by the list of items to be read.
 
However scanf wants to know the address of the items to be read, since it is a function which will change that value. Therefore the names of variables are preceeded by the & sign.
 
Character strings are an exception to this. Since a string is already a character pointer, we give the names of string variables unmodified by a leading &.
 
Control string entries which match values to be read are preceeded by the percentage sign in a similar way to their printf equivalents.
 
2. Unformatted console I/O:
 
This function cannot control the format of reading and writing the data. some of the example of this function are getch( ),getche( ),getchar( ),gets( ),putchar( ),putch( )and puts( ).
 
getchar
 
getchar returns the next character of keyboard input as an int.
 
If there is an error then EOF (end of file) is returned instead. It is therefore useful to compare this value against EOF before using it.
 
If the return value is stored in a char, it will never be equal to EOF, so error conditions will not be handled correctly.
 
As an example, here is a program to count the number of characters read until an EOF is encountered. EOF can be generated by typing Control - d.
 
 
Output of the program:
 
 
putchar
 
putchar puts its character argument on the standard output (usually the screen).
 
The following example program converts any typed input into capital letters.
 
To do this it applies the function toupper from the character conversion library ctype.h to each character in turn.
 
An example program using putchar.
 
 
Output of the program:
 
 
gets
 
gets reads a whole line of input into a string until a newline or EOF is encountered. It is critical to ensure that the string is large enough to hold any expected input lines. When all input is finished, NULL as defined in stdio.h is returned
 
puts
 
puts writes a string to the output, and follows it with a newline character.
 
An example program which uses gets and puts to double space typed input
 
 
Out put of the program
 
 
 
Note: putchar, printf and puts can be freely used together. So can getchar, scanf and gets.