Function Computer Science Project Class 10th

1064

“Function”

The function is a self contained block of statements which performs a coherent task of same kind.

C program does not execute the functions directly. It is required to invoke or call that function. When a function is called any program then program control goes to the function body. Therefore, it is possible to call function whenever we want to process that functions statements.

Library Functions :

Library Functions are present in the C library and they are predefined. To use library function we have to include corresponding header file. For example, to use input output functions like printf () and scanf (), we have to include stdio.h.

Standard Input and Output Functions :

The standard input and output functions are defined in stdio.h header file. To include these functions in our program, we should use # include<stdio.h> statement in the beginning of the program. Some function are printf(), putchar (), scanf(), and getchar ().

getchar () :

The getchar () function is used to read a character from the keyboard.

syntax : char ch;

. ch = getchar ();

Putchar () :

The Putchar () function is used to print a character on the screen.

syntax : int putchar (char ch);

Program :

# include <stdio.h>

void main ()

{

char ch;

printf (“Enter a characte :”);

ch= getchar ();

putchar (ch);

}

Mathematical functions :

Mathematical functions are the functions defined in the Haider file math.h.

log ()

The log () function returns the natural logarithm of a number of the type double it successful.

sintex : double log (double X);

pow ()

This function calculates a value that is x raised to the power y.i.e.x power y.

syntax : double row ( double x, double y);

sqrt ()

This function is used to find the square root of a number.

syntax : float sqrt (float num);

exp ()

This function is used to find the exponential value of a number.

syntax : float exp (float num);

sin () This function is used to find out the sine value of an angle.

syntax : double sin (double x);

Program :

# include <studio.h>

# include <math.h>

void main ()

{

int a = 30;

printf (“% d % It %, abs (a), log (a), sqrt (a)”);

}

Character functions :

Character functions are the functions that operate on character. These functions are define in ctype.h header file.

isupper () :

This function is used to check the given character is in upper case or not.

sintex : int is upper (char ch);

islower () :

This function is used to to check the given character is in lower case or not.

sintex : int is lower (char ch);

toupper () :

This function is used to convert lowercase character into upper case character.

syntax : char toupper

tolower () :

This function is used to convert uppercase character into lowercase character.

syntax : char tolower (char ch);

isdigit () :

This function is used to check the given character is a digit or not.

syntax : int isdigit (int ch);

Program :

# include <stdio.h>

# include <ctype.h>

void main ()

{

char ch;

printf (” Enter a character :”);

ch = getchar ();

if ( isupper (ch))

printf (“character is upper case letter”);

}

Conclusion :

This project provides as the knowledge of library function and their uses.

VIVA-VOCE QUESTION

Ques.1 What is the default return type of a user defined function?

Ans. void.

Ques.2 Which function is necessary in a valid C program?

Ans. main () function is necessary in a C program.

Ques.3 Which function call it self?

Ans. Recursive functions repeatedly call it self.

Ques.4 Which function executes first in C program?

Ans. main () function.

Read also :

C programming (Array) computer project Class 10

Computer Science Project Work-4 Class 10th

Class 10th Computer Science Project Work-3

LEAVE A REPLY

Please enter your comment!
Please enter your name here