Skip to main content

Posts

Showing posts with the label library function

Types of Functions in C Programming

C program has two types of functions: 1. Library Functions 2. User defined functions Library Functions: These are the functions which are already written, compiled and placed in C Library and they are not required to be written by a programmer. The function’s name, its return type, their argument number and types have been already defined. We can use these functions as required. For example: printf(), scanf(), sqrt(), getch(), etc. User defined Functions: These are the functions which are defined by user at the time of writing a program. The user has choice to choose its name, return type, arguments and their types. The job of each user defined function is as defined by the user. A complex C program can be divided into a number of user defined functions. For example: #inlcude<stdio.h> double convert (int) ; /* function proto type */ main() { int c ; /* double d ; */ printf (“Enter temperature in Celsius: ”) ; scanf (“%d”, &c) ; /* d =...

Exit( ) function in C programming

We have already known that we can jump out of a loop using either the break statement or goto statement. In a similar way, we can jump out of a program by using the library function exit( ). In case, due to some reason, we wish to break out of a program and return to the operating system. The general syntax is - - - - - - - - - - if (condition) exit (0) ; - - - - - - - - - - The exit( ) function takes an integer value as its argument. Normally zero is used to indicate normal termination and non zero value to indicate termination due to some error or abnormal condition. The use of exit( ) function requires the inclusion of the header file <stdio.h>. /* Program to demonstrate exit( ) */ #include<stdio.h> #include<stdlib.h> main() { int choice ; while(1) { printf (“ 1. Create database\n”) ; printf (“ 2. Insert new record\n”) ; printf (“ 3. Modify a record\n”) ; printf (“ 4. Delete a record\n”) ; printf (“ 5. Display all records...