Saturday, March 6, 2021

, , , ,

Example program for isprint() in c

 The isprint() function in c programming is used to check the given character is a printable character or not.

Printable characters in c programming are just the opposite of control characters and these type of characters checked using iscntrl() function in c.

Syntax for isprint() in c

int isprint( int arg );

for return value if the given characters passed to isprint() function in c is a printable character then it return non-zero integer otherwise return zero.

isprint() in c takes argument in the form of integer and returns.

Example for C isprint() function

 

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

int main()
{
    char c;

    c = 'Q';
    printf("Result when a printable character %c is passed to isprint(): %d", c, isprint(c));

    c = '\n';
    printf("\nResult when a control character %c is passed to isprint(): %d", c, isprint(c));

    return 0;
}

 OUTPUT : - 

C isprint()
C isprint() function in c

 

Monday, March 1, 2021

, , , ,

Example program for isgraph in c

 The isgraph() function in c use to checks that given character is a graphic character or not.

What is graphic character:- Characters which have graphical representation are call as graphic characters. 

isgraph in c return the non zero integer if passed argument is an 
graphic character otherwise returns 0.

Syntax for isgraph in c 

int isgraph(int argument);

 Example program to Check graphic character with help of isgraph in c

 

#include <stdio.h>
#include <ctype.h>
int main()
{
    char c;
    int result;

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

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

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

 OUTPUT : -

When   is passed to isgraph() = 0
When 
 is passed to isgraph() = 0
When 9 is passed to isgraph() = 1
, , , ,

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
, , , ,

Example program for islower() function in c

 The islower() function in c checks  that the given character is lowercase alphabet (a-z) or not.

Syntax :- 

int islower( int arg );

 islower() function takes a single argument in the form of  integer and return the value of integer type.

Return Value islower() function in c : -


  • Non-zero number (x > 0)  it means given Argument is a lowercase alphabet.
  • Zero (0) then given Argument is not a lowercase alphabet.


Example for C islower() function in c


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

int main()
{
    char c;

    c='t';
    printf("Return value when %c is passed to islower(): %d", c, islower(c));

    c='D';
    printf("\nReturn value when %c is passed to islower(): %d", c, islower(c));

    return 0;
}

Output

Return value when t is passed to islower(): 2 Return value when D is passed to is islower(): 0

Friday, February 26, 2021

, , ,

Example program for isupper() function in c

As it's name says isupper() function in c programming checks whether given character is an uppercase alphabet (A-Z) or not.

C isupper() syntax : - 

int isupper(int argument);
  • isupper() function takes a single argument in the form of int.
  • Given argument converted into to its ASCII for the check.
  •  isupper() define in <ctype.h> header file.

 C isupper() Function Return Value

 

isupper in c
isupper in c

Example program for C isupper() function


#include <stdio.h>
#include <ctype.h>
int main()
{
    char c;

    c = 'C';
    printf("Return value when uppercase character %c is passed to isupper(): %d", c, isupper(c));

    c = '+';
    printf("\nReturn value when another character %c is passed to is isupper(): %d", c, isupper(c));

   return 0;
}


, , , ,

Example program for isalnum() function in c

 The isalnum() function in C use to checks given argument  is an alphanumeric character (alphabet or number) or not.

Syntax : -

int isalnum(int argument);

This function is define in ctype.h header file.

Return Value For isalnum() function in c

it return 1 if given argument in program is an alphanumeric character.


isalnum() function return 0 if given argument in program is not an alphabet or a digit.

Example program for isalnum() function in c

#include <stdio.h>
#include <ctype.h>
int main()
{
    char c;
    int result;

    c = '5';
    result = isalnum(c);
    printf("When %c is passed, return value is %d\n", c, result);

    c = 'Q';
    result = isalnum(c);
    printf("When %c is passed, return value is %d\n", c, result);

    c = 'l';
    result = isalnum(c);
    printf("When %c is passed, return value is %d\n", c, result);

    c = '+';
    result = isalnum(c);
    printf("When %c is passed, return value is %d\n", c, result);

    return 0;
}

 

 Output of Program

  • When 5 is passed, return value is 1
  • When Q is passed, return value is 1
  • When l is passed, return value is 1
  • When + is passed, return value is 0

 

 

Thursday, February 25, 2021

, , , ,

Example Program for isdigit() in c - Function in c

 isdigit() function in C programming use to checks whether a character is numeric character (0-9) or not.

 Prototype of isdigit() Function in C

int isdigit( int arg );


  • isdigit() function in c programming take a single argument which is an integer and return type int.
  • Given character is converted to its ASCII value in isdigit() Function
  • It is defined in <ctype.h> header file in c.

Return value for C isdigit()

isdigit() Return value in c
 isdigit() Return value in c


Example Program for isdigit() function in c


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

int main()
{
    char c;
    c='5';
    printf("Result when numeric character is passed: %d", isdigit(c));

    c='+';
    printf("\nResult when non-numeric character is passed: %d", isdigit(c));

    return 0;
}

OUTPUT : - 

Result when numeric character is passed: 1
Result when non-numeric character is passed: 0