Showing posts with label iscntrl(). Show all posts
Showing posts with label iscntrl(). Show all posts

Monday, March 1, 2021

, , , ,

Example program for iscntrl() function in c

  •   iscntrl() function in c Used to check if the given character is a control character or not.
  • Characters that are not print on the screen are known as control characters for exam newline.
  •  If a character passed by iscntrl() function is a  control character then it  return non zero integer value otherwise return 0. 
  •   iscntrl() C is define in ctype.h header file.
  • this function  takes a single argument and returns an integer.


Syntax for iscntrl() in c :-

int iscntrl(int argument);

Example program for iscntrl() in c : -

 

#include <stdio.h>
#include <ctype.h>

int main()
{
    char c;
    int result;

    c = 'Q';
    result = iscntrl(c);
    printf("When %c is passed to iscntrl() = %d\n", c, result);

    c = '\n';
    result = iscntrl(c);
    printf("When %c is passed to iscntrl() = %d", c, result);

    return 0;
}

 OUTPUT : -

When Q is passed to iscntrl() = 0
When 
 is passed to iscntrl() = 1