c i/o operations tutorial

Bodhak c io Operations tutorial in this chapter we will discuss in detail along with syntax’s and examples about I/O Operations in C, Formatted and Unformatted functions, Working with printf function, Working with scanf function, Declaring variables, Rules for declaring variables, Initializing variables.

I/O Operations in C: Console I/O functions are mainly classified into two categories. Unformatted console  I/O functions &   Formatted console I/O  functions



c io Operations tutorial:-

Working with print () function:

Output data can be written from the computer onto a standard output device using the library function printf().  The printf() function moves data from the computer’s memory to the standard output device.

The printf() function moves data from the computer’s memory to the standard output device.

Syntax:  print f(control string, arg1,arg2,arg3,……..argN);

Where control string refers to a string that contains formatting information, and arg1,arg2,……argN are arguments that represent the individual output data items.

In contrast to the input functions. The arguments in a print f () function do not represent memory addresses.

The control string is composed of characters, with one character group for each output data item. Each character group must begin with a percent sign (%).

In its simplest form, an individual character group will consist of the percent sign followed by a conversion character indicating the type of the corresponding data item.

Multiple character groups can be contiguous, or other characters, including white space character, can separate them.  The use of blank spaces as character-group separators is particularly common

Declaring variables:

The Declaration of variable tells the compiler about the  identifier(variable name & its data type)

EX:    int simple;

int total, Avg;

float amount;

char choice;

 Scope Of Variable:

Variables have 2 types of scopes



Local: We should declare this variable within the function and it becomes available to that specific function statements.

Global: We Should declare this variable Outside the function it becomes available to all the statements in that program

Rules for Constructing variable:

  • A variable name is a combination of alphabets, digits & underscore
  • Max length is:8 char Min length is: 1 char
  • it must start with alphabet
  • Special characters are not allowed except the underscore.

EX  : float tot_amt;

int sub1mark;

Next Page