7 : strrev(string) - String Reverse :This function is used to reverse a string. This function takes
only one argument and return one argument.
Syntax : strrev(string);
Ex : Program using strrev() function
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
C PROGRAMMING Page 131
,char str[20];
printf("Enter the string:");
scanf("%s",str);
printf("The string reversed is:%s",strrev(str));
getch();
}
OUTPUT : Enter the string :subbareddy
The string reversed is : ydderabbus
UNIT – III
FUNCTIONS:
User‐Defined Functions
Definition: A function is a block of code/group of statements/self contained block of statements/
basic building blocks in a program that performs a particular task. It is also known
as procedure or subroutine or module, in other programming languages.
To perform any task, we can create function. A function can be called many times. It
provides modularity and code reusability.
C PROGRAMMING Page 132
, Advantage of functions
1) Code Reusability
By creating functions in C, you can call it many times. So we don't need to write the same code
again and again.
2) Code optimization
It makes the code optimized we don't need to write much code.
3) Easily to debug the program.
Example: Suppose, you have to check 3 numbers (781, 883 and 531) whether it is prime number or
not. Without using function, you need to write the prime number logic 3 times. So, there is repetition of
code.
But if you use functions, you need to write the logic only once and you can reuse it several times.
Types of Functions
There are two types of functions in C programming:
1. Library Functions: are the functions which are declared in the C header files such as
scanf(), printf(), gets(), puts(), ceil(), floor() etc. You just need to include appropriate
header files to use these functions. These are already declared and defined in C
libraries. oints to be Remembered
System defined functions are declared in header files
System defined functions are implemented in .dll files. (DLL stands for Dynamic Link
Library).
To use system defined functions the respective header file must be included.
2. User-defined functions: are the functions which are created by the C programmer, so
that he/she can use it many times. It reduces complexity of a big program and optimizes
the code. Depending upon the complexity and requirement of the program, you can create
as many user-defined functions as you want.
C PROGRAMMING Page 133
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller akhilagouri. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for £15.79. You're not tied to anything after your purchase.