tag:blogger.com,1999:blog-87384210609603554022024-03-05T17:52:03.285+05:30Sharing ZoneProgramming Language in C & C++Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-8738421060960355402.post-66905000586785924002014-02-06T11:01:00.000+05:302014-02-06T11:01:01.639+05:30Make INDIA Map using C Program<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-ld-Ye-nPlb1OB5VhpBTR9lN8MwKq9vPHRAcmLaoGP8DMAiTJr3Fy-vjo4VRK-7jf_OD2iAGQz48mcnN3ue_qSVCg9nFLeyh48uXLXq2j7g2SM8UgwK8bDCXNrkxTvu_q0juC39Yq7L0/s1600/download.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-ld-Ye-nPlb1OB5VhpBTR9lN8MwKq9vPHRAcmLaoGP8DMAiTJr3Fy-vjo4VRK-7jf_OD2iAGQz48mcnN3ue_qSVCg9nFLeyh48uXLXq2j7g2SM8UgwK8bDCXNrkxTvu_q0juC39Yq7L0/s1600/download.jpg" /></a></div>
#include<stdio.h><br />
int main (void)<br />
{<br />
int a=10, b=0, c=10;<br />
char* bits ="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";<br />
a = bits[b];<br />
while (a != 0)<br />
{<br />
a = bits[b];<br />
b++;<br />
while (a > 64)<br />
{<br />
a--;<br />
if (++c == 'Z')<br />
{<br />
c /= 9;<br />
putchar(c);<br />
}<br />
else<br />
{<br />
putchar(33 ^ (b & 0x01));<br />
}<br />
}<br />
}<br />
return 0;<br />
}<br />
<div>
<br /></div>
<br /></div>
Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-16753366191778088052013-09-15T21:08:00.002+05:302014-02-25T10:56:32.414+05:30Swap two variable value within one line statement using c program<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWOdwLWCj7cqVtNHA_xP9dZ_PtOBoKnWgyJVGnOKPy-b0ivjIOppDQfieE76mOlB4rlH_hUPWrB06sEcG3cMUBplijxQeKYBc3gatdmaUnjh-r2lF508GAnOkat8qGloJ4kOQ-PwZr_PD5/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWOdwLWCj7cqVtNHA_xP9dZ_PtOBoKnWgyJVGnOKPy-b0ivjIOppDQfieE76mOlB4rlH_hUPWrB06sEcG3cMUBplijxQeKYBc3gatdmaUnjh-r2lF508GAnOkat8qGloJ4kOQ-PwZr_PD5/s1600/images.jpg" /></a></div>
<br />
#include<stdio.h><br />
void main()<br />
{<br />
int a=10;<br />
<br />
int b=20;<br />
<br />
printf("a value is = %d b value is = %d \n",a,b);<br />
<br />
<span class="n" style="line-height: 1.1em;">a</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="o" style="line-height: 1.1em;">=</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="p" style="line-height: 1.1em;">(</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="n" style="line-height: 1.1em;">a</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="o" style="line-height: 1.1em;">+</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="n" style="line-height: 1.1em;">b</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="p" style="line-height: 1.1em;">)</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="o" style="line-height: 1.1em;">-</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="p" style="line-height: 1.1em;">(</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="n" style="line-height: 1.1em;">b</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="o" style="line-height: 1.1em;">=</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="n" style="line-height: 1.1em;">a</span><span style="background-color: #f6f6f6; line-height: 1.1em;"> </span><span class="p" style="line-height: 1.1em;">);</span><br />
<br />
printf("a value is = %d b value is = %d \n",a,b);<br />
<br />
}</div>
Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com1tag:blogger.com,1999:blog-8738421060960355402.post-28812053314869623222013-06-07T02:18:00.002+05:302013-06-07T02:18:27.425+05:30NQueen Problem <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ1v8Bkmp_OZ1DxctYuiMEYmezG36KcPhUrTj13Gs0qF7asyITqO7a6H_XxMX-xp_nalpypNGYY1EVR5JShuS7MJQVT6bV6O1Nu0FmGrLAkKYN3MaB32noKTH_rZ1F30Fi-7hho-jtoYpv/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ1v8Bkmp_OZ1DxctYuiMEYmezG36KcPhUrTj13Gs0qF7asyITqO7a6H_XxMX-xp_nalpypNGYY1EVR5JShuS7MJQVT6bV6O1Nu0FmGrLAkKYN3MaB32noKTH_rZ1F30Fi-7hho-jtoYpv/s1600/images.jpg" /></a></div>
#include<stdio.h><br />
int x[20], n, k = 1;<br />
void nqueens();<br />
void main() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int i, j;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>clrscr();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n Enter the no of queens");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>scanf("%d", &n);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>nqueens();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (k > n)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n queen placement on board :\n");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (i = 1; i <= n; i++)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (j = 1; j <= n; j++)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (j == x[i])<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("Q%d\t", i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("*\t");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n queen can not be placed");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>getch();<br />
}<br />
<br />
void nqueens() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int i;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while (k <= n && k >= 0)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>x[k] += 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (i = 1; i < k && x[k] <= n; i++)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ((x[i] == x[k]) || (abs(x[i] - x[k]) == abs(i - k)))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>x[k] += 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>i = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (x[k] > n)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>--k;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>k++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>x[k] = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}</div>
Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-25523539770243793342013-06-07T02:05:00.000+05:302013-06-07T02:10:55.577+05:30Contact<div dir="ltr" style="text-align: left;" trbidi="on">
Email :- bapankarak@gmail.com</div>
Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-11906008391073403312012-06-06T22:55:00.000+05:302012-06-06T22:55:55.561+05:30Dangling pointer in c programming<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;">In this pointer is pointing the memory address of variable but after some variable has deleted from that memory location </span><span style="background-color: white; color: #222222; font-family: 'Courier New'; font-size: 14pt; text-align: justify;">while </span><span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;">pointer is still pointing such memory location. Such pointer is known as dangling pointer.</span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><br /></span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><br /></span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><b><u>Example</u></b> :</span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><br /></span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><br /></span><br />
<span style="background-color: white; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><br /></span><br />
<span style="background-color: white; color: blue; font-family: 'Courier New'; font-size: 14pt; text-align: justify;">#include</span><span style="background-color: white; color: #a31515; font-family: 'Courier New'; font-size: 14pt; text-align: justify;"><stdio.h></span><br />
<span style="background-color: white; text-align: justify;"></span><span style="color: #a31515; font-family: 'Courier New';"><span style="font-size: 19px;"><br style="background-color: white; text-align: justify;" /></span></span><br />
<div style="text-align: justify;">
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: #7f0055; font-family: 'Courier New'; font-size: 14pt;">int</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt;"> * fun()</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt;">{</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: #7f0055; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">static int</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;"> a=99;</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">++a;</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: #7f0055; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">return</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;"> &a;</span></div>
<div style="background-color: white; line-height: 24px; text-indent: 0.5in;">
<span style="font-size: medium;"><span style="color: blue; font-family: 'Courier New'; font-size: 14pt;"></span></span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt;">}</span><span style="color: blue; font-family: 'Courier New'; font-size: 14pt;"></span></div>
<br class="Apple-interchange-newline" />
<!-----></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: #7f0055; font-family: 'Courier New'; font-size: 14pt;">void</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt;"> main()</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt;">{</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: #7f0055; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">int</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;"> *p;</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">p=fun();</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">fflush(stdin);</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">printf(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">"%d"</span><span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">,*p);</span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt; text-indent: 0.5in;">}</span></div>
<div style="background-color: white; line-height: 24px; text-align: justify;">
<span style="font-size: medium;"><span style="color: blue; font-family: 'Courier New'; font-size: 14pt;"></span></span></div>
<div style="background-color: white; line-height: 24px; text-align: justify;">
<span style="color: #7f0055; font-family: 'Courier New';"><span style="font-size: 19px;"><br /></span></span></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 18px; line-height: 24px; text-align: justify;">
<span style="color: black; font-family: 'Courier New'; font-size: 14pt;">Output: 100</span></div>
<br class="Apple-interchange-newline" />
<!--En--></div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-66751166821095182532012-06-01T20:40:00.001+05:302012-06-11T01:24:05.746+05:30Binary Tree Traversal Using Recursive and Non Recursive Function in C<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
#include<stdio.h><br />
#include<conio.h><br />
#include<alloc.h><br />
<br />
typedef struct bint<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int data,flag;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>struct bint *left,*right;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}node;<br />
<br />
node * create(node *r,int d)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(r == NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>r = (node *)malloc(sizeof(node));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>r->data = d;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>r->left = r->right = NULL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(r->data <= d)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>r->right = create(r->right,d);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>r->left = create(r->left,d);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return r;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
<br />
<br />
void inorder(node *r)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(r != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>inorder(r->left);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",r->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>inorder(r->right);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
void non_in(node *r)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int top=0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>node *s[20],*pt=r;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>s[0]=NULL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(pt != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>s[++top] = pt;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = pt->left;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = s[top--];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(pt != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",pt->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(pt->right != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = pt->right;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(pt != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>s[++top] = pt;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = pt->left;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = s[top--];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
<br />
void preorder(node *r)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(r != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",r->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>preorder(r->left);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>preorder(r->right);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
void non_pre(node *r)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int top=0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>node *s[20],*pt=r;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>s[0]=NULL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(pt != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",pt->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(pt->right != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>s[++top] = pt->right;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(pt->left != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = pt->left;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pt = s[top--];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
void postorder(node *r)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(r != NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>postorder(r->left);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>postorder(r->right);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",r->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
void non_post(node *root)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>node *stack[100];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int top=-1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>node *temp=root;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(temp!=NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(temp!= NULL)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>top++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>stack[top] = temp;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>temp = temp->left;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>label:temp =stack[top];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>top--;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(temp->flag==1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d\t",temp->data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>temp->flag=1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>top++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>stack[top] = temp;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>temp=temp->right;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(top>=0)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>goto label;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
<br />
void main()<br />
{<br />
int d;<br />
char ch = 'Y';<br />
node *head = NULL;<br />
clrscr();<br />
while(toupper(ch) == 'Y')<br />
{<br />
printf("\n Enter the item to insert");<br />
scanf("%d",&d);<br />
head = create(head,d);<br />
printf("\n Do you want to continue(y/n)");<br />
fflush(stdin);<br />
ch = getchar();<br />
}<br />
printf("\ninorder recursive\n");<br />
inorder(head);<br />
printf("\ninorder non recursive\n");<br />
non_in(head);<br />
<br />
printf("\n\n");<br />
printf("\npostorder rrecursive\n");<br />
postorder(head);<br />
printf("\npostorder non recursive\n");<br />
non_post(head);<br />
<br />
printf("\n\n");<br />
printf("\npreorder recursive\n");<br />
preorder(head);<br />
printf("\npreorder non recursive\n");<br />
non_pre(head);<br />
getch();<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Any problem in program please comment .......</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com7tag:blogger.com,1999:blog-8738421060960355402.post-76383176126636243882012-05-29T07:51:00.002+05:302012-06-11T01:24:36.749+05:30Overloading the output operator in c++<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre style="font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">#include <iostream>
using namespace std;
class x
{
int i;
public:
x(int k)
{
i=k;
}
friend ostream& operator<<(ostream& os, const x& d1);
};
ostream& operator<<(ostream& os, const x& d1)
{
os << d1.i ;
return os;
}
int main()
{
x s1(20);
cout << s1;
}</pre>
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-1593305490954271442012-05-27T22:32:00.002+05:302012-05-27T22:50:09.536+05:30How to find out if a processor is Little-Endian Big-Endian<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
#include<stdio.h><br />
<br />
main()<br />
{<br />
int num = 1;<br />
if(*(char *)&num == 1)<br />
{<br />
printf("\nLittle-Endian\n");<br />
}<br />
else<br />
{<br />
printf("Big-Endian\n");<br />
}</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-8424350056348470642012-05-26T21:48:00.000+05:302012-05-26T21:48:21.932+05:30Difference between c and c++<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<ul style="text-align: left;">
<li><span style="background-color: transparent;">Actually c is a procedural programming language which </span><span style="background-color: transparent;">cann't face the real world problem. It has some drawback </span><span style="background-color: transparent;">like a global data is shared by all function and if in a </span><span style="background-color: transparent;">large program it is find out difficult that which function </span><span style="background-color: transparent;">uses which data. </span></li>
</ul>
<span style="background-color: transparent;"> On the other hand c++ is an object oriented programming </span><span style="background-color: transparent;">language which eliminate some pitfall of </span><br />
<span style="background-color: transparent;"> conventional or </span><span style="background-color: transparent;">procedural programming language. It is a concept or </span><span style="background-color: transparent;">approach for designing a new </span><br />
<span style="background-color: transparent;"> software. It is nothing to do </span><span style="background-color: transparent;">with any programming language although a programming </span><span style="background-color: transparent;">language which </span><br />
<span style="background-color: transparent;"> support the oops concept to make it easier </span><span style="background-color: transparent;">to implement </span><br />
<span style="background-color: transparent;"><br /></span><br />
<span style="background-color: transparent;"></span><br />
<br />
<ul style="text-align: left;">
<li><span style="background-color: transparent;"> In object oriented programming, the programmer can solve</span><span style="background-color: transparent;">problems by breaking them down into real-life objects (it</span><span style="background-color: transparent;">presented the programmer with an opportunity to mirror real</span><span style="background-color: transparent;">life). What is an object? This topic is dealt with </span><span style="background-color: transparent;">extensively in the chapter on ‘Objects and Classes’ but a</span><span style="background-color: transparent;">brief introduction is provided here.</span></li>
</ul>
<br />
<span style="background-color: transparent;"> Example Consider the category of cars. All cars have some common </span><span style="background-color: transparent;">features (for example all cars have </span><br />
<span style="background-color: transparent;"> four </span><span style="background-color: transparent;">wheels, an engine, </span><span style="background-color: transparent;">some body colour, seats etc.). Are all cars the same? Of </span><span style="background-color: transparent;">course not. A Fiat and a </span><br />
<span style="background-color: transparent;"> Ford aren’t the same but they are </span><span style="background-color: transparent;">called as cars in general. In this example cars will form a </span><span style="background-color: transparent;">class and </span><br />
<span style="background-color: transparent;"> Ford (or Fiat) will be an object.</span><br />
<br />
For those people who know C programming, it would be useful <span style="background-color: transparent;">to know the differences between C and </span><br />
<span style="background-color: transparent;"> C++. Basically C++ </span><span style="background-color: transparent;">includes everything present in C but the use of some C </span><span style="background-color: transparent;">features is deprecated in </span><br />
<span style="background-color: transparent;"> C++ .</span><br />
<br />
<br />
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-1551315145965894722012-05-25T23:51:00.001+05:302012-05-25T23:51:13.005+05:30Circular Queue insert delete operation using c<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
#include <stdio.h><br />
#include<ctype.h><br />
#include<stdlib.h><br />
#define MAXSIZE 5<br />
int cq[MAXSIZE];<br />
int front,rear;<br />
void main()<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>void add(int,int);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>void del(int);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int will=1,i,num;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>front = -1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>rear = -1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>clrscr();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\nProgram for Circular Queue demonstration through array");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nMAIN MENU\n1.INSERTION\n2.DELETION\n3.EXIT");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nENTER YOUR CHOICE : ");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>scanf("%d",&will);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>switch(will)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>case 1:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nENTER THE QUEUE ELEMENT : ");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>scanf("%d",&num);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>add(num,MAXSIZE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>case 2:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>del(MAXSIZE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>case 3:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> exit(0);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>default: printf("\n\nInvalid Choice . ");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
} <br />
void add(int item,int MAX)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span style="background-color: transparent;">if(front ==(rear+1)%MAX)</span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nCIRCULAR QUEUE IS OVERFLOW");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> if(front==-1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> front=rear=0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> rear=(rear+1)%MAX;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> cq[rear]=item;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> printf("\n\nRear = %d Front = %d ",rear,front);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
void del(int MAX)<br />
{<br />
int a;<br />
if(front == -1)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nCIRCULAR QUEUE IS UNDERFLOW");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>a=cq[front];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(front==rear)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> front=rear=-1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> front = (front+1)%MAX;<br />
printf("\n\nDELETED ELEMENT FROM QUEUE IS : %d ",a);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("\n\nRear = %d Front = %d ",rear,front);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-70315171730698408172012-04-26T20:37:00.002+05:302012-04-26T20:37:53.086+05:30Doubly linkked list insert , delete, any position using c++<div dir="ltr" style="text-align: left;" trbidi="on">
#include<iostream.h><br />#include<conio.h><br />#include<process.h><br />class list<br />{<br /> struct dlist<br /> {<br /> int data;<br /> struct dlist *left_link,*right_link;<br /> };<br />struct dlist *head;<br />public:<br />list(){head=NULL;}<br />void add(int pos,int i);<br />void del();<br />void dis();<br />};<br /><br />void list::add(int pos,int i)<br />{<br /> struct dlist *temp,*p;<br /> temp=new dlist;<br /> temp->data=i;<br /> temp->left_link=temp->right_link=NULL;<br /> switch(pos)<br /> {<br /> case 1: temp->right_link=head;<br /> head=temp;<br /> break;<br /> case 2:<br /> p=head;<br /> while(p->right_link!=NULL)<br /> p=p->right_link;<br /> p->right_link=temp;<br /> temp->left_link=p;<br /> break;<br /><br /> case 3:<br /> cout<<"Enter position";<br /> int pos;<br /> cin>>pos;<br /> p=head;<br /> for(int i=2;i<pos;i++)<br /> p=p->right_link;<br /> temp->right_link=p->right_link;<br /> p->right_link=temp;<br /> temp->left_link=p;<br /> temp->right_link->left_link=temp;<br /> break;<br /> }<br /><br />}<br />void list::dis()<br />{<br /> struct dlist *temp;<br /> temp=head;<br /> while(temp!=NULL)<br /> {<br /> cout<<temp->data;<br /> temp=temp->right_link;<br /> }<br /> getch();<br />}<br />void list::del()<br />{<br /> struct dlist *temp;<br />cout<<"1 to first\n2 to last\n3 to any pos";<br />int pos;<br />cin>>pos;<br />temp=head;<br />switch(pos)<br />{<br /> case 1: head=temp->right_link;<br /> delete(temp);<br /> break;<br /> case 2:<br /> while(temp->right_link!=NULL)<br /> temp=temp->right_link;<br /> temp->left_link->right_link=NULL;<br /> delete(temp);<br /> break;<br /> case 3:<br /> cout<<"Enter position";<br /> int ps;<br /> cin>>ps;<br /> for(int i=2;i<ps;i++)<br /> temp=temp->right_link;<br /> temp->right_link= temp->right_link->right_link;<br /> temp->right_link->left_link=temp;<br /> break;<br />}<br />}<br /><br />void main()<br />{<br />int ch;<br />list s;<br />while(1)<br />{ clrscr();<br />cout<<"\n1 to insert"<<"\n2 to delete"<<"\n3 to display"<<"\n4 to exit";<br />cin>>ch;<br />switch(ch)<br />{<br />case 1: cout<<"1 to first pos\n2 to last pos\n3 to any pos\n";<br /> int pos,item;<br /> cin>>pos;<br /> cout<<"Enter element:";<br /> cin>>item;<br /> s.add(pos,item);<br /> break;<br /><br />case 2: s.del();<br /> break;<br />case 3:<br /> s.dis();<br /> break;<br />case 4:<br /> exit(0);<br />}<br />}<br />}</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-30885061868952501012012-01-19T02:08:00.000+05:302012-01-19T02:08:18.954+05:30Find sum of array element . Then sort the element<div dir="ltr" style="text-align: left;" trbidi="on"><br />
#include<stdio.h><br />
#include<conio.h><br />
void main()<br />
{<br />
int a[10],i,j,s=0;<br />
clrscr();<br />
<br />
printf("Enter the elements of The Array: ");<br />
for(i=0;i<10;i++)<br />
{<br />
scanf("%d",&a[i]);<br />
s=s+a[i];<br />
}<br />
<br />
for(i=0;i<s;i++)<br />
{<br />
for(j=0;j<10;j++)<br />
{<br />
if(a[j]==i)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>printf("%d ",a[j]);<br />
}<br />
}<br />
getch();<br />
}<br />
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com1tag:blogger.com,1999:blog-8738421060960355402.post-72712785501891839122011-12-28T08:02:00.000+05:302011-12-28T08:07:52.526+05:30Difference between getch(), getchar(), and getche()?<div dir="ltr" style="text-align: left;" trbidi="on"><span style="background-color: black;"><span style="color: white;"> <b style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Verdana, sans-serif; font-size: 12px; line-height: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Getchar()</b><span style="font-family: Verdana, sans-serif; font-size: 12px; line-height: 12px;"> will accept a character from keyboard displays immediately while typing and need Enter key to pressed for proceeding</span></span></span><br />
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: black;"><span style="color: white;"><br />
<b style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Verdana, sans-serif; font-size: 12px; line-height: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Getch()</b><span style="font-family: Verdana, sans-serif; font-size: 12px; line-height: 12px;"> Normally we will use it at the end of the main(). It just accepts a key stroke and never displays it and proceeds further.</span></span></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Verdana, sans-serif; font-size: 12px; line-height: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: black;"><span style="color: white;"><br />
<br />
<b style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Getche()</b> will accept a character from keyboard display it immediately does not wait for Enter key to pressed for proceeding.</span></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: black;"><br />
</span> <br />
</span></span></span></div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-32609149206384888682011-12-27T17:23:00.000+05:302011-12-27T17:23:16.629+05:30Disadvantage of void pointer<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<ul style="text-align: left;"><li><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;">It can not perform arithmetic operation.</span></li>
<li><span style="font-family: Wingdings; text-indent: -0.25in;"><span style="font: 7.0pt "Times New Roman";"> </span></span><span style="text-indent: -0.25in;">Sizeof(void) //is illegal </span><span style="text-indent: -0.25in;"> </span><span style="text-indent: -0.25in;"> </span></li>
</ul></div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-33010154426217702042011-12-25T17:06:00.000+05:302012-06-11T01:21:35.676+05:30Bubble short Ascending in c<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
#include<stdio.h><br />
void main()<br />
{<br />
int i,j,n,temp,a[100];<br />
clrscr();<br />
printf("Enter how many number do you Enter");<br />
scanf("%d",&n);<br />
printf("Enter number");<br />
for(i=0;i<n;i++)<br />
scanf("%d",&a[i]);<br />
for(j=0;j<n;j++)<br />
{<br />
for(i=j+1;i<n;i++)<br />
{<br />
if(a[j]>a[i])<br />
{<br />
temp=a[j];<br />
a[j]=a[i];<br />
a[i]=temp;<br />
}<br />
}<br />
}<br />
printf("Ascending order is: ");<br />
for(i=0;i<n;i++)<br />
printf("%d,",a[i]);<br />
getch();<br />
}</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-12181543910938253712011-12-25T16:07:00.001+05:302012-06-11T01:21:58.578+05:30How to print void pointer value in c ?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
#include<stdio.h></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
#include<conio.h></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
void main()</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
{</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
int a,*p;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
char s;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
float f;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
void *v;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
clrscr();</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("Enter integer:");</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
scanf("%d",&a);</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
v=&a;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
p=v;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("Integer number is:%d%d\n",(*(int*)v),p);</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("Enter a character:");</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
scanf("%s",&s);</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
v=&s;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("character is:%c\n",(*(char*)v));</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("Enter float number");</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
scanf("%f",&f);</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
v=&f;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
printf("Float number is:%f\n",(*(float*)v));</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; margin-left: 0.5in; margin-right: 0in; margin-top: 0in; text-indent: 0.5in;">
getch();</div>
<div class="MsoNormal" style="text-indent: .5in;">
}</div>
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com0tag:blogger.com,1999:blog-8738421060960355402.post-9222395189092081642011-12-25T13:47:00.001+05:302012-06-11T01:22:22.749+05:30Advantage of void pointer in c.<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoListParagraphCxSpFirst" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<div style="text-align: left;">
<span style="font-family: Wingdings; text-indent: -0.25in;"><span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="text-indent: -0.25in;">I use a void pointer it store any data type.</span></div>
</div>
<div class="MsoListParagraphCxSpLast" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="font-family: Wingdings;"><span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span>It save memory space.</div>
</div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com1tag:blogger.com,1999:blog-8738421060960355402.post-10599739500258513642011-12-25T13:30:00.000+05:302011-12-25T13:31:43.306+05:30what is void pointer?<div dir="ltr" style="text-align: left;" trbidi="on">A void pointer is pointer which has no specified data type . The keyword ‘void’ is preceded the pointer variable because the data type is not specified . It is also know as generic pointer . The void pointer can be pointed to any type of variable address and data.<br />
<div class="MsoNormal"><br />
</div><div class="MsoNormal">Eg:</div><div class="MsoNormal"> Void main()</div><div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">{</div><div class="MsoNormal" style="margin-left: 1.0in; text-indent: .5in;">Void *p;</div><div class="MsoNormal" style="margin-left: 1.0in; text-indent: .5in;">Int a;</div><div class="MsoNormal" style="margin-left: 1.0in; text-indent: .5in;">P=&a;</div><div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">}</div></div>Soumen Karakhttp://www.blogger.com/profile/13341200231775991943noreply@blogger.com1