Unformatted input/output functions in c language

 Unformatted Input/Output Function -

# Input functions- 

Getchar(), getch(), getche(), gets() etc. 

# Output functions-

Putchar(), putch(), and puts() etc. 


Input Functions -

getchar()- 

Getchar() function will read or display 
 a single character from the standard input.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
k =getchar();
getch();

}

getch()-

getch () reads a single character from standard input .the input character is not displayed on the screen. getch()
return when the first char is entered 
and does not wait for enter to be key pressed.

Example  -
#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
Printf("enter any character");
Scanf("%x",&k); 
k=getch();
getch();
}

getche()-

getche() is same as getch () except that 
it echoes the input character.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
Printf("enter any character");
Scanf("%c",&k) ;
k =getche();
Printf("ASCII number of character
 %c is %d",chili, ch);
getch();
}

gets()-

This function is displayed a set of character or string.
Example -


#include <stdio.h>
#include <Conio.h>
void main ()
{
char str[ 10]; 
gets(str);
getch();
}

Putchar()-

Putchar() will print a single character on standard input. The characters to be 
Printed is passed to putchar () as an arrangement. The character return value of putchar () is the character which was written to the output.
Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
getchar(k);
getch();
}

Putch()-
Putch () is writing a character that is passed as an arrangement to the
 console.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
k =getch();
Putch(k);
getch();
}

Puts()-
This function is displayed or read a set of character or string. 

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char ste[20]; 
gets(str);
puts(str);
getch();

}



Type conversion and advantages disadvantage

 Type conversion -

A type cast is basically a conversion from one type to another.
There are two types -

1. Implicit type conversion 
2. Xplicit type conversion 

1. Implicit conversion -

It is also known as automatic type conversion. Done by the compiler on its own, without any external trigger from the user. Generally takes place when in an expression more than one data type is present. All the data types of the variables are upgraded to the type of the variable with largest data type.

2. Xplicit conversion -

This process is also called type casting 
and it is user defined. Here the user
can type cast the result to make it of 
a particular data type.

Advantage -

Compiler automatically converted from lower data type to higher data type so program need not about conversion proceduce.

Disadvantage -

. Possible only if the data type of two operand are different.
. Conversion from higher data type to lower is not possible.

Operator in c language

 What is operator -

An operator is a symbol that specific
 that operator an activity to be perform.
Classification of operators are given below -


Arithmetic operator - 

The operator that are used to perform 
arithmetic operator such as addition,
Subtraction, multiplication, etc are called arithmetic operator.

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int a, b, c; 
Printf("Enter the value of a and b");
Scanf("%d%d", &a, &b);
C=a+b;
Printf("value of c", c);
getch();
}

Assignment operator -

An operator which used to copy the data or results of an expression. assignment operator copy or storing is to a memory is called assigning. The assignment is denoted by single.

Example -

# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k, r; 
k=20;
r=k;
Printf("Enter the value of k =%d",k);

Printf("Enter the value of r =%d",r);

getch();
}

Increment operator -

There are two types -

1. Post increment operator -

If the increment operator "++" his placed the operand than then the operand is called post increment.

Example -

# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k=20;
k++;
Printf("Enter the value of k =%d",k);
getch();
}

2. Pre increment operator -
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k=20;
++k;
Printf("Enter the value of k =%d",k);
getch();
}

Decrement operators -

"--" is a decrement operators. It Decreament the value of operand by one.  These are two types -


1. Post decrement operator -

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k=20;
k--;
Printf("Enter the value of k =%d",k);
getch();
}


2. Pre decrement operator -

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k=20;
--k;
Printf("Enter the value of k =%d",k);
getch();
}

Relational operator -


The representation operator is also called compression operator are used
 to to fine the relationship between two 
Operand are called representation 
Operator.

Example -

# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k=20 r=10;
If(k>r)
{

Printf(" This value is greater ");
}
Else {
Printf("this value is not greater");
}
getch();
}

Logical operator -


As we have logical get such as AND, OR,  
And NOTE. Whose output is one or arrow one or NOT.  He also have logical operator after evaluate expression consisting of logical operator. 
Results in either true or false. 

Conditional operator -


It is also called ternary operator as the name of indiget an operator that operator on three operand.

Example-
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k,r,g;

Printf("Enter the value of k and r");
Scanf("%d%d",&k, &r); 
G= (k>r)?k:r;
Printf("value of G=%d",G);
getch();
}

Bit Wise operator -

The data is store in the memory enterm 
Of binary digits such as 0 and 1. Sometimes it's may be necessary to manipulate. These operator that are used manipulate the bit are called bit wise operator.

1. Bit wise AND -

If the corresponding bit position in both the operand are one then AND operator results in one. Otherwise AND operator results in zero.

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k,r,g;
g = k&r;
Printf("%d&%d=%d",k,r,g);
getch();
}


2. Bit wise OR -

If the corresponding bit position in both the operand are zero then OR operator results in zero . Otherwise OR operator results in one.

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k,r,g;
g = k/r;
Printf("%d/%d=%d",k,r,g);
getch();
}

3. Bit wise X-OR -
It the position of both operand are different then operation results in one otherwise results in zero.

Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int  k,r,g;
g = k^r;
Printf("%d^%d=%d",k,r,g);
getch();
}

Data type in c language

Data Types -

Data types are mean to identify the type of data associate of operations for handling. It is the type of the value that a variable can store in the memory is called data type.


There are three types -

1. Primitive Data type 
2. User data type 
3. Derived data type 

1. Primitive data type -
 These are classified as 

Int
Char
Float 
Double 
Void 

Int -  It is a keyword while is used to define int number both positive and negative numbers can be store in the memory.
Example - int a=10;

Float - It is use to define floating point number. It is also called real number. This data type both positive and negative floating point number can be store in the memory.
Example - float a=5.6;

Char- It is a keyword while is used to define char can be store character in the memory.
Example - char= 'L'; 

Double -  It is used to define store floating point number with double precision.

Void -  it is the empty data type it is normally used in functions to indicate that the function does not return any value since no value is associated with this data type. It does not a copy any space in the memory. It is not associate with any variables expect pointer.

2. User define data type -

A special data type that is defined by user from the drived is called user define data type.
Example - structure,  union, class etc

3. Derived data type -

Derived data types are built from the fundamental or basic data type.
Example - array, function,pointer etc.




Variables in c language

 Variables -

A variable is defined as the name given to a memory location. Where  the data 
Can be store accessed or manipulated in which is used to store a value is called variable.
 


There's two types -

1. Internal/local variable 
2. External/Global variable 


1. Local variable -

Local variables are declared inside a 
Particular functions. They are local to particular functions. They are declared inside a function. In which they are to be initialized . They are private property 
Of a particular function and can not be 
Exit outside.

Example-
  #included <stdio. h>
    Void main()
{
  Int a=10;
Printf("value of a");
getch();
}

Global variable -

Global variable declared outside the function. They can use in whole program.

Example -
#included <stdio. h>
    Void main()
Int a=20;
{
a =10; 
Printf("value of a");
getch();
}

C Tokens

 C TOKENS-

A token is a smallest or basic unit of any program one or more character are grouped in sequence of from meaningful word. These meaningful words are called tokens. 




Tokens can be classified as-
1. keyword
2. Identifiers 
3. Constant
4. operator
5. special symbols

1. Keyword-

The keyword that have predefined meaning for compiler are called keyword since,
They are receiver for special purpose in c language.
eg-   int, void, if , else, float, char, do, for, switch, etc.

2. Identifier- 

An identifier is a synonyms of the to name. It is a word consisting of a sequence of one or more latter
or digits along only special character under score.

3. Constant-

A constant is a data item which will not be change during the execution program the constant 
in c languages are-

Integer constant-   It is a whole number without any decimal point.
Example-01,10,26,9 etc

floating constant-    The numeric value having fractional part are called floating point.
character constant.
Example-  3.4,8.6, 9.8 etc

string constant-   A sequence of character enclosed with a pair of double "" is called string constant.
Example-  "Gugu" , "kamini", "Rahul" etc

Character constant-  A character enclosed with a pair of single ' ' is called character constant. 
Example- 'a' ,  'b' etc.

4. Operator-

operators are the word of a language that helps the users performs computation on value. 
the value that can be operator by these operators are called.

Unary operator-  c has a class of operator that out upon a single operator to give a new 
value which type of operators are called unary operator.

Binary operator-  Binary operator requirement two variable to be evaluated +, -, *, %.

Structure of c language

Structure of c

The structure of c program is nothing but the way of framing the group of statement while writing a c program. Step to learn c language. we have arrived to a conclusion that a program us a collection of statement.



1. Documentation Section-

This section is used to declaration of the program name or comments.

2. Pre-processor Directives-

This section is used to start with # symbol. These statement instruct the compiler to include the specified file in the begenning of the program.
E.G-     "#include "

3. Global Declaration-

The variable that are declaration all the function are called Global variable. All the function can access these variable by default the global variable initialised with zero.

4. Main() -

Each and every c programs should have a function main() and this function is always executed first. The statement is closed with in left and right curly braces "{ }" are called body of function.

5. Declaration Section-

The local variable that are to be used in the main() should declaration in this section.

6. Executable Section-

This section contain the builting block of the program. The block containing executable statement represent the direction given to the processor to perform the task.

7. User Defined Function-

This is last optical selection of the program structure. The function write by the user to perform particular task are called user Defined function.

program

Write a program to print the messag 

                  #include <stdio.h>

                 void main()
                 {
             printf("This is C programming Tutorial");
             getch();
                 }

                                
                                                     

Program Development of life cycle

 Program development is not a single activity but a multi-step process. Each step comprises of specific type of activities. All the steps  of program development put through are often referred to as program development life cycle. 

Program development  life cycle steps are given below -



1. Understanding the problem -

For writing a program , you have to understand the problem first,  unless you understand the problem clearly you will not be able to write the program.

2. Planning the solution-

Planning the solution means finalizing all those steps that are to be carried out for solving the problem. This step is often referred to as algorithms development or logic development phase.

3. Coding -

Refer all above mentioned steps and note that these steps are simply a plan on paper for attaining a solution, not the exact solution. The exact solution has to exist in the form of command written in computer language.

4 .Editing, Compiling and Executing-

In the phase, program is written on computer using a text editor. After entering the program in compiled so that the sentences of the program gets converted into machine language.

5. Debugging -

Newly development program may have few error in it. These errors can occur due to various reasons. Either you may have forgotten some of the steps or you may have performed wrong operations or you may have used wrong logic in the program. All such type of errors have to be found our in the program and corrected so that the program gives correct results. This process finding mistakes in the program and correcting them called debugging.

6. Documentation -

A correct program is of very little use. Unless it is supported by full description in writing. Detailed description of the program is called documentation.


Features of c language

 Features of c -

The c language being a middle level language has many important features. It is said to be middle level language because of the following features .



1. Implementation of modular programming technique is very easy in the case of c language because of the easy designing and handling of module.

2. Each and every task using c language is solve by means of functions only so it is called functional language.

3. User can define there own task in the form of user define function.

4. It has large collection of built in or library functions that make the programming easier.

5. It is rich in operators contening very common arithmetic operator and other.

6. C language are portable and can be executed at different platforms.

7. C language is a case sensitive programming language.

8. Implementation of structured programming technique is easy because of beaching and looping structure.

Note -

C language is near to machine as well as the user , it is called middle level language . The compbility of low level language,  help in designing the programs specially require system management . It means system software can be developed very easy.

                     It is also near to the user most general purpose program can be developed easly so the application program can also be developed.




characteristics of c language

 Characteristics of c programming language 

There's following characteristics of programming, which are given below -



(1) Accurate -  

The programming of a program is a based on certain problem. The problem must be pre-defined clearly with specification of retirement. So the designed program must be accurate to perform the specific task.

(2) Efficient  -

It means the program must not spend much time or over use the processor in executing it's code.

(3) Maintainable -

It means the availability to change age per the now need. With very little modification a program should work for the new needs.

(4) Portable -

It means the program can be easily transfer from one machine to another machine and programs can be carry to any platform to solve the task.

(5) Readable -

The program is also read by co-programmer so the designed program must contain proper comments to explain the code. 

(6) Reliable -

This is the most important characteristics of programming ,program should be reliable.

(7) Robust -

The designed program is expected to continue with its functions even at the an expected error.

(8) Useable -

Program must be easy to use. It must be designe with proper interactive message so that the user can easily got it.

(9) Documentation -

The uses of comments or remarks to explain the code interaction and the mode use of the program is called documentation.



Introduction of c programming language

Introduction of c language 

 C language is programming language developed at Bell Laboratories of USA in 1972 written by Dennis Ritchie. Computer language are written in computer language each computer language is different from others c, c++,Java, visual basic etc. 



○Learning of any language start with sequential steps _


Step 1: As the first step before leaning any language we learn the alphabet of the language. The alphabet is called character set.


Step 2:  We learn how one or more character can be grouped together to from meaningful word are called tokens.


Step 3:  We learn how one or more sentence are grouped together to from meaningful sentence is called statement.


Step 4:  We learn how one or more statement are grouped together to from set of paragraph is called program.


History of c progamming language/History of c

 History of C Language


The c programming language is a structure oriented programming language at Bell Laboratories of American Telephone & Telegraph  in 1972(U.S.A) By Dennis Ritchie. C language was invented for implementing UNIX operating system. and it was developed to overcome the problems of previous language as if B,BCPL ANSI C and Algol etc.




Now we will discus you about the developed language before c language-----

Language                 Developed By                              Year  

Algol                       International group                      1960

BCPL                     Martin Richard                              1967

B                             Ken Thompson                            1970

Traditional C           Dennis Ritchie                             1972

K & R C                  Kernighan& Dennis Ritchie         1978

ANSIC                    ANSI Committee                          1989

ANSI/ISO C          ISO Committee                              1990 

C99                      Standardization Committee             1999


There are three types of c language-


  • Low level language
  • Assembly language
  • High level language