Monday, March 1, 2021

, , , ,

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

 

 

, , ,

Example program for isalpha in c - Function In C

 The isalpha() function in  programming is used to check whether a character is an alphabet or not.

If a character is prove that it is an is an alphabet with the help of isalpha() function in c then it return non zero integer otherwise it gives zero. 

This function is define in the <ctype.h> header file in c.

C isalpha() Prototype

int isalpha(int argument);

isalpha() function in c takes a single argument in the form of integer and give an integer value.

Return Value For isalpha() in C

Return Value For isalpha()
Return Value For isalpha()


Example Program: C isalpha() function

#include <stdio.h>
#include <ctype.h>
int main()
{
    char c;
    c = 'Q';
    printf("\nResult when uppercase alphabet is passed: %d", isalpha(c));

    c = 'q';
    printf("\nResult when lowercase alphabet is passed: %d", isalpha(c));

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

    return 0;
}
OUTPUT : - 
Result when uppercase alphabet is passed: 1
Result when lowercase alphabet is passed: 2
Result when non-alphabetic character is passed: 0 
 

Monday, December 21, 2020

, ,

r plot program example and how to use it.

 R Plot Function is used to plot a graph in r programming in this r function we can vector and then we get a graph which is about  magnitude vs index.

r plot function has so many method which is called according to the passed value to this r plot function.

For example we pass two vector plot(c(1,2),c(3,5)) and then this function plot a scatter graph for these two point.

here we plot graph for sine function form range -pi to pi as you can see in this picture.


<- pi="" plot="" pre="" seq="" sin="" x="">x <- seq(-pi,pi,0.1) plot(x, sin(x))

 

R Plot Function
 R Plot Function

Adding Titles and Labeling Axes to the r plot function

Here you can add title and label to the with parameter main and xlab and ylab two parameter for labeling x-axis and y-axis in plot graph.

plot(x, sin(x),
main="The Sine Function",
ylab="sin(x)")

 

Axes to the r plot function
Labeling Axes to the r plot function

 Changing Color and Plot Type for r function : -

 Well you can change the color for plot type with the help of the argument type in r languages.

Check out the example for r plot with color:- 

plot(x, sin(x),
main="The Sine Function",
ylab="sin(x)",
type="l",
col="blue")

 here we can define the color with col

 

changing Color and Plot Type
changing Color and Plot Type

 

Friday, December 18, 2020

,

Use of clrscr function in c with example

 clrscr function in C programming is use to clear the screen and move the arrow upper left-hand corner of your computer screen.

this function work only for the GCC compiler otherwise use clear/cls command.

Example program for clrscr function in c

#include<stdio.h>
#include<conio.h>

int main()
{
   printf("Press any key to clear the screen.\n");

   getch();

   clrscr();

   printf("This appears after clearing the screen.\n");
   printf("Press any key to exit...\n");

   getch();
   return 0;
}

As you can see with the help of printf function computer is asking to press any key to clear the screen and then the second message will be displayed.