Sunday 9 July 2017

Getchar

Getchar Function

Getchar takes input a character from standard input (stdin) and return integer value without sign.

int main(void)
{
   int c;

   /* Note that getchar reads from stdin and

Saturday 8 July 2017

getche

Getche function

Getche is same as getch function, both takes input from keyboard the difference is return type.
  • Getch does not echo given character only return integer value
  • Getche  echo and return integer code of given character

#include<stdio.h>
void main()
{
    char n;

Getch

Getch takes input a character from keyboard.  Getch is different from scanf because user need to press enter explicitly to complete input process but getch intensely return pressed key ASCII.

Some people used getch  to hold program output because when getch excuted it wait for a character and until user press a character next statement would not get executed.

Friday 7 July 2017

Switch Case C Language

Switch Case


A switch case is uncomplicated solution/alternate of complicated nested if-else. It is useful when there is a need check to arise multiple possibility on single variable like print day of the week name based on the given day number. Best for long if statements that compare a variable to several "integral" values ("integral" values are simply values that can be expressed as an integer, such as the value of a char).

Switch case syntax

Above figure is showing syntax of switch case. In syntax break and default are in bracket, which means they are optional. You can use more than one case without using break. If break is omitted, then all the ca