<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>c pointers Archives -</title>
	<atom:link href="https://mitindia.in/tag/c-pointers/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/c-pointers/</link>
	<description></description>
	<lastBuildDate>Tue, 05 Jul 2016 11:14:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>c pointers Archives -</title>
	<link>https://mitindia.in/tag/c-pointers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Functions and Pointers</title>
		<link>https://mitindia.in/functions-and-pointers/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Tue, 05 Jul 2016 07:06:36 +0000</pubDate>
				<category><![CDATA[C Programming]]></category>
		<category><![CDATA[c pointers]]></category>
		<category><![CDATA[functions]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=252</guid>

					<description><![CDATA[<p>Functions and Pointers in C language A function is a unit or module within a program that can be called as and when necessary and as many times as we wish within a program to solve a particular task. When program becomes complex, it is difficult handle or debug, so the complex program can be [&#8230;]</p>
<p>The post <a href="https://mitindia.in/functions-and-pointers/">Functions and Pointers</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Functions and Pointers in C language</h3>
<p>A function is a unit or module within a program that can be called as and when necessary and as many times as we wish within a program to solve a particular task.</p>
<p>When program becomes complex, it is difficult handle or debug, so the complex program can be split into small parts or modules and each module can perform different task or function. These small parts of a complex program are called functions.</p>
<p>Functions can be re-used as many times in the same program or can be used in other programs</p>
<p><span style="color: #ff0000;"> Benefits of using functions:-</span></p>
<ul>
<li>Reduce the effort taken to program</li>
<li>Enable placing of common block of statements separately instead of repetitively within a program, thus providing re-usability</li>
<li>Help to reduce errors and enable faster debugging</li>
<li>Enable categorizing code into libraries which can be used for large projects</li>
</ul>
<p><span style="color: #ff0000;">Types of Functions:-</span><br />
<em>1. Built-in functions</em>: C provides a large number of built-in functions, which are defined in header files (.h files).</p>
<p><em>2. User defined function</em>: User defined functions are those functions which are written by the user according to his/her need within a program</p>
<pre>/* function with arguments and with return values */
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
main()
{
int a,b,res;

/* function declaration */
add();
sub();
mul();
div();

clrscr();
/* input output operations */

printf("Enter two numbers:");
scanf("%d%d", &amp;a,&amp;b);

res=add(a,b);
printf("sum=%d\n", res);

res=sub(a,b);
printf("sub=%d\n", res);

res=mul(a,b);
printf("multiplication=%d\n", res);

res=div(a,b);
printf("division=%d\n", res);

getch();
}

/* functions calling */

int add(int x, int y)
{
int t=x+y;
return(t);
}

int sub(int x, int y)
{
int t=x-y;
return(t);
}

int mul(int x, int y)
{
int t=x*y;
return(t);
}

int div(int x, int y)
{
int t=x/y;
return(t);
}</pre>
<p>Function to display Total marks.</p>
<pre>#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
main()
{
int s1,s2,s3,tot;
float avg;

clrscr();

printf("Enter 3 subjects marks: ");
scanf("%d%d%d", &amp;s1, &amp;s2, &amp;s3);

tot=total(s1,s2,s3);
avg=average(s1,s2,s3);

printf("Total marks : %d \n", tot);
printf("Average marks : %f\n", avg);
getch();
}

int total(int x, int y, int z)
{
int t=x+y+z;
return(t);
}
int average(int x, int y, int z)
{
float t=(float)(x+y+z)/3.0;
return(t);
}

</pre>
<pre>/* function with no arguments and no return values */
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
main()
{
clrscr();
display();
getch();
}
display()
{
printf("inside the sub-function.....");
}</pre>
<pre>/* function with argements but no return values */
#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
main()
{
int a,b;
clrscr();

printf("Enter two numbers:");
scanf("%d%d", &amp;a, &amp;b);

large(a,b);
getch();
}

int large(int x, int y)
{
if(x&gt;y)
{
printf("a is large");
}
else
{
printf(" b is large");
}
}</pre>
<pre>C Program to demonstrate built-in math function</pre>
<pre>#include&lt;conio.h&gt;
#include &lt;stdio.h&gt;
#include &lt;math.h&gt;
main()
{
double result, x = 1.0;
clrscr();
result = sin(x);
printf("The sin() of %lf is %lf\n", x, result);
return 0;
}

C Program to demonstrate built-in string function 

#include&lt;conio.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
main()
{
char str[20];
int len;
clrscr();
printf("Enter string :");
scanf("%s", str);

printf("\n\nINPUT string : %s\n", str);
printf("lower case string : %s \n", strlwr(str));
printf("Upper case string : %s \n", strupr(str));

len=strlen(str);
printf("Length of the string : %d", len);
getch();
}</pre>
<pre><span style="color: #ff0000;">Pointers</span>:- <b>Pointer is a variable that holds  memory address of another variable.</b></pre>
<pre><b>A pointer provides a way of accessing a variable value without referring to the variable directly. </b></pre>
<p><span style="color: #ff0000;">Use of Pointers:-</span></p>
<ol>
<li>To return more than one value from a function.</li>
<li>To pass arrays more conveniently from one. function to another.</li>
<li>To manipulate arrays easily by moving pointers to them.</li>
<li>To allocate memory and access it.</li>
</ol>
<div>Simple C Program to demonstrate pointers</div>
<div>
<pre>#include&lt;stdio.h&gt;
#include&lt;conio.h&gt;
main()
{
int x,y;
int *ptr1, *ptr2;
clrscr();
x=2, y=3;
ptr1=&amp;x;
ptr2=&amp;y;
printf("\n Pointers \n");
printf("the value of x : %d\n", x);
printf("the address of x : %u\n", ptr1);
printf("the value of y : %d\n", y);
printf("the address of y : %u\n", ptr2);
getch();
}</pre>
</div>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Ffunctions-and-pointers%2F&amp;linkname=Functions%20and%20Pointers" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Ffunctions-and-pointers%2F&amp;linkname=Functions%20and%20Pointers" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Ffunctions-and-pointers%2F&#038;title=Functions%20and%20Pointers" data-a2a-url="https://mitindia.in/functions-and-pointers/" data-a2a-title="Functions and Pointers"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/functions-and-pointers/">Functions and Pointers</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
