<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6206379159301365957</id><updated>2024-08-29T14:12:42.934-07:00</updated><category term="c++"/><category term="c++ programs"/><category term="polymorphism"/><category term="runtime"/><category term="runtime polymorphism"/><title type='text'>CODING DATA STRUCTURE</title><subtitle type='html'> ONE SOLUTION FOR DATA STRUCTURE PROBLEM.&#xa;FOR Online Assistance and help @email:Learnprogramm@gmail.com</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Hemant Gupta</name><uri>http://www.blogger.com/profile/07066850715894356667</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>141</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-2715737567874764768</id><published>2012-03-26T05:49:00.001-07:00</published><updated>2012-11-20T06:46:20.480-08:00</updated><title type='text'>SINGLE LINKED LST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&lt;a href=&quot;http://codingdatastructure.blogspot.com/&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
//Insertion and Deletion in Single Linked List&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
#include&amp;lt;conio.h&amp;gt;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
#include&amp;lt;alloc.h&amp;gt;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
struct sll&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{int info;sll*next;};&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
sll *create(sll**sl)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{*sl=NULL;return *sl;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
sll*alloc()&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{return (sll*)malloc(sizeof(sll));}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
void insert(sll**sl,int loc,int item)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{sll* temp,*ptr;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr=alloc();&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr=*sl;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
temp=alloc();&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
temp-&amp;gt;info=item;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;if(*sl==NULL)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{temp-&amp;gt;next=NULL;(*sl)=temp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;else if(loc==0)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{temp-&amp;gt;next=(*sl);(*sl)=temp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;else&amp;nbsp; if(loc==-1)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{while(ptr-&amp;gt;next!=NULL)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;&amp;nbsp; {ptr=ptr-&amp;gt;next; }&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; temp-&amp;gt;next=NULL;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; ptr-&amp;gt;next=temp;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;else{for(int i=1;i&amp;lt;loc;i++)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr=ptr-&amp;gt;next;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;temp-&amp;gt;next=ptr-&amp;gt;next;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr-&amp;gt;next=temp;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
int deletion(sll**sl,int loc)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{sll*temp,*ptr; int c; temp=alloc();&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr=alloc();ptr=*sl ;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;if(*sl==NULL)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{printf(&quot;sll is empty&quot;);getch();exit(0);}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;if(loc==0)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{c=(*sl)-&amp;gt;info;*sl=(*sl)-&amp;gt;next;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;else if(loc==-1)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{while(ptr-&amp;gt;next-&amp;gt;next!=NULL)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; ptr=ptr-&amp;gt;next;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; c=ptr-&amp;gt;next-&amp;gt;info;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; ptr-&amp;gt;next=NULL;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;else&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;{ for(int i=1;i&amp;lt;loc;i++)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;&amp;nbsp; {ptr=ptr-&amp;gt;next;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;temp=ptr-&amp;gt;next;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;c=temp-&amp;gt;info;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;ptr-&amp;gt;next=temp-&amp;gt;next;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;}return c;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
void display(sll**sl)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{printf(&quot;\n&quot;);sll*temp;temp=alloc();temp=*sl;&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
while(temp!=NULL)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp; {printf(&quot;%d&quot;,temp-&amp;gt;info);temp =temp-&amp;gt;next;}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
void main()&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
{clrscr();&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
sll*s;int r;s=create(&amp;amp;s);&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
&amp;nbsp;//loc=0 =&amp;gt;beg,loc=-1 =&amp;gt;last,loc=n =&amp;gt; after nth node(n=1,2..)&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
insert(&amp;amp;s,0,4);display(&amp;amp;s);&amp;nbsp; //loc=0&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
insert(&amp;amp;s,0,5) ;display(&amp;amp;s);&amp;nbsp; //loc=0&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
insert(&amp;amp;s,-1,8);display(&amp;amp;s);&amp;nbsp; //loc=-1&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
insert(&amp;amp;s,0,9);display(&amp;amp;s);&amp;nbsp;&amp;nbsp;&amp;nbsp; //loc=0&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
insert(&amp;amp;s,2,10);display(&amp;amp;s);&amp;nbsp;&amp;nbsp; //loc=2&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
r=deletion(&amp;amp;s,0);printf(&quot;\nDeleted element %d&quot;,r);//loc=0&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
r=deletion(&amp;amp;s,0);printf(&quot;\nDeleted element %d&quot;,r);//loc=0&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
r=deletion(&amp;amp;s,1);printf(&quot;\nDeleted element %d&quot;,r);//loc=1&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
getch();&lt;/div&gt;
&lt;div class=&quot;MsoNoSpacing&quot;&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/2715737567874764768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2012/03/single-linked-lst.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2715737567874764768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2715737567874764768'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2012/03/single-linked-lst.html' title='SINGLE LINKED LST'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-6177752325008425963</id><published>2012-03-26T05:42:00.001-07:00</published><updated>2012-03-26T05:42:17.864-07:00</updated><title type='text'>ADT_BINARY SEARCH TREE</title><content type='html'>&lt;div class=&quot;gmail_quote&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;div class=&quot;gmail_quote&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;#include&amp;lt;alloc.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;#include&amp;lt;process.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;struct node&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{node *left,*right;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; int info;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;};&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;node *create(node* *r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {(*r)=NULL; return (*r);}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;node *alloc()&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {return (node*) malloc(sizeof(node));}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void in_traverse(node **r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {if(*r!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {in_traverse(&amp;amp;(*r)-&amp;gt;left);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;     printf(&amp;quot;  %d-&amp;gt; &amp;quot;,(*r)-&amp;gt;info);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    in_traverse(&amp;amp;(*r)-&amp;gt;right);}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void pre_traverse(node **r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {if((*r)!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {printf(&amp;quot;  %d-&amp;gt;&amp;quot;,(*r)-&amp;gt;info);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    pre_traverse(&amp;amp;(*r)-&amp;gt;left);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    pre_traverse(&amp;amp;(*r)-&amp;gt;right);}&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void post_traverse(node **r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {if((*r)!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {post_traverse(&amp;amp;(*r)-&amp;gt;left);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;     post_traverse(&amp;amp;(*r)-&amp;gt;right);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    printf(&amp;quot;  %d-&amp;gt;&amp;quot;,(*r)-&amp;gt;info);}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void preorder(node**r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {node*stack[20],*ptr;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  int top=0;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  stack[top]=NULL;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  ptr=(*r);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  while(ptr!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   { printf(&amp;quot;  %d-&amp;gt;&amp;quot;,ptr-&amp;gt;info);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  if(ptr-&amp;gt;right!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   { top++; stack[top]=ptr-&amp;gt;right;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  if(ptr-&amp;gt;left!=NULL)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;   ptr=ptr-&amp;gt;left;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   { ptr=stack[top]; top--;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void inorder(node**r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{node*stack[20],*ptr; int top=0;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; stack[top]=NULL; ptr=(*r);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; again:while(ptr!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {top++; stack[top]=ptr; ptr=ptr-&amp;gt;left;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; ptr=stack[top];top--;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; while(ptr!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {printf(&amp;quot;  %d-&amp;gt;&amp;quot;,ptr-&amp;gt;info);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  if(ptr-&amp;gt;right!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {ptr=ptr-&amp;gt;right;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  goto again;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  ptr=stack[top];top--;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; typedef struct&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {node*pr;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; char status;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }pnode;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; pnode *alloc1()&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {return (pnode*)malloc(sizeof(pnode));}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; void postorder(node**r)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {pnode*stack[20],*temp,*myptr=NULL; int top=0;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  node*ptr=NULL; stack[top]=NULL; ptr=(*r);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; again:  while(ptr!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {top++; temp=alloc1();&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;     temp-&amp;gt;pr=ptr;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;     temp-&amp;gt;status=&amp;#39;p&amp;#39;;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;     stack[top]=temp;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    if(ptr-&amp;gt;right!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {top++; temp=alloc1();&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;    temp-&amp;gt;pr=ptr-&amp;gt;right;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    temp-&amp;gt;status=&amp;#39;n&amp;#39;;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;    stack[top]=temp;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   ptr=ptr-&amp;gt;left;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  myptr=stack[top]; ptr=myptr-&amp;gt;pr; top--;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  while(myptr-&amp;gt;status==&amp;#39;p&amp;#39;)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {printf(&amp;quot; %d-&amp;gt;&amp;quot;,ptr-&amp;gt;info); myptr=stack[top];&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   ptr=myptr-&amp;gt;pr; top--;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  if(myptr-&amp;gt;status==&amp;#39;n&amp;#39;)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  {myptr-&amp;gt;status=&amp;#39;p&amp;#39;;ptr=myptr-&amp;gt;pr;goto again; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;void insert(node**r,int data)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{node*temp,*save,*ptr;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;if((*r)==NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; { (*r)=alloc();(*r)-&amp;gt;left=NULL;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   (*r)-&amp;gt;info=data;(*r)-&amp;gt;right=NULL;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; else&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; { if(data&amp;lt;(*r)-&amp;gt;info) insert(&amp;amp;((*r)-&amp;gt;left),data);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else insert(&amp;amp;((*r)-&amp;gt;right),data);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;void del(node**r,int data)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{node*ptr,*ptr1,*ptr2,*ptr3;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;ptr=alloc();ptr1=alloc();ptr2=alloc();ptr3=alloc();&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; ptr=ptr1=(*r);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;ptr2=ptr3=NULL ;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;while(ptr!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{  if(ptr-&amp;gt;info==data)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {if(ptr-&amp;gt;left!=NULL&amp;amp;&amp;amp;ptr-&amp;gt;right!=NULL)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;      {ptr2=ptr-&amp;gt;right;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;      ptr3=ptr;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;      while(ptr2-&amp;gt;left!=NULL)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;       {ptr3=ptr2; ptr2=ptr2-&amp;gt;left;}&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ptr-&amp;gt;info=ptr2-&amp;gt;info;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if(ptr2-&amp;gt;right!=NULL)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;{ptr3-&amp;gt;left=ptr2-&amp;gt;right;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else {if(ptr==ptr3)ptr3-&amp;gt;right=NULL;else ptr3-&amp;gt;left=NULL; }&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;      }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else if((ptr-&amp;gt;left==NULL&amp;amp;&amp;amp;ptr-&amp;gt;right!=NULL)||(ptr-&amp;gt;left!=NULL&amp;amp;&amp;amp;ptr-&amp;gt;right==NULL))&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {if(ptr-&amp;gt;left==NULL)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;   {ptr1-&amp;gt;right=ptr-&amp;gt;right;   ptr=NULL;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   else {ptr1-&amp;gt;right=ptr-&amp;gt;left;ptr=NULL;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else {&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  if(ptr1-&amp;gt;right-&amp;gt;info==data)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {ptr1-&amp;gt;right=NULL;ptr=NULL;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;   {ptr1-&amp;gt;left=NULL;ptr=NULL;}&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;      }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;      }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; else if(ptr-&amp;gt;info&amp;gt;data)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {ptr1=ptr;ptr=ptr-&amp;gt;left;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  else&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; {ptr1=ptr;ptr=ptr-&amp;gt;right;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;void main()&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;{  clrscr(); int ch1;           int i,ch;&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt; node* r1; r1=alloc(); r1=create(&amp;amp;r1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; do{ printf(&amp;quot;OPERATIONS ON BINARY SEARCH TREE&amp;quot;);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  printf(&amp;quot;\n1.Insertion\t2.Traversal\t3.Deletion\t4.exit&amp;quot;);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  printf(&amp;quot;\nEnter your choice&amp;quot;);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  scanf(&amp;quot;%d&amp;quot;,&amp;amp;ch);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  switch(ch)&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  {case 1:printf(&amp;quot;enter element to insert&amp;quot;);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  scanf(&amp;quot;%d&amp;quot;,&amp;amp;i);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; insert(&amp;amp;r1,i);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; break;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; case 2: printf(&amp;quot;Traversal using 1.stacks\t2.recursion&amp;quot;);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt; scanf(&amp;quot;%d&amp;quot;,&amp;amp;i);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt; if(i==1)&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt; { printf(&amp;quot;\nPREORDER USING STACKS&amp;quot;);preorder(&amp;amp;r1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;   printf(&amp;quot;\nPOSTORDER USING STACKS&amp;quot;);postorder(&amp;amp;r1);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;   printf(&amp;quot;\nINORDER USING STACKS&amp;quot;);inorder(&amp;amp;r1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;   }&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;   else&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;  {  printf(&amp;quot;\nPREORDER USING RECURSION&amp;quot;);pre_traverse(&amp;amp;r1);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt; printf(&amp;quot;\nPOSTORDER USING RECURSION&amp;quot;);post_traverse(&amp;amp;r1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; printf(&amp;quot;\nINORDER USING RECURSION&amp;quot;);in_traverse(&amp;amp;r1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  }&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  break;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; case 3:  printf(&amp;quot;enter element to delete&amp;quot;);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;  scanf(&amp;quot;%d&amp;quot;,&amp;amp;i);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; del(&amp;amp;r1,i);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt;  break;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; case 4:exit(0);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;default:printf(&amp;quot;wrong choice&amp;quot;);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; printf(&amp;quot;Do you want to continue(1 for yes\t0 for no)&amp;quot;);&lt;/div&gt; &lt;div class=&quot;gmail_quote&quot;&gt; scanf(&amp;quot;%d&amp;quot;,&amp;amp;ch1);&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }while(ch1==1) ;&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; getch();&lt;/div&gt;&lt;div class=&quot;gmail_quote&quot;&gt; }&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/6177752325008425963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2012/03/adtbinary-search-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/6177752325008425963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/6177752325008425963'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2012/03/adtbinary-search-tree.html' title='ADT_BINARY SEARCH TREE'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4416338997415089524</id><published>2011-12-26T19:11:00.001-08:00</published><updated>2011-12-26T19:11:34.216-08:00</updated><title type='text'>HYBRID INHERITANCE</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;/*PROGRAM To show hybrid inheritance*/&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;class student&lt;br&gt;{protected:int roll_num;&lt;br&gt; public:&lt;br&gt;void get_num(int a)&lt;br&gt; {roll_num=a;}&lt;br&gt;void put_num()&lt;br&gt; {cout&amp;lt;&amp;lt;&amp;quot;Roll number: &amp;quot;&amp;lt;&amp;lt;roll_num&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;}&lt;br&gt;};&lt;br&gt;class test:public student&lt;br&gt;{protected:float sub1,sub2;&lt;br&gt;public:&lt;br&gt; void get_marks(float x,float y)&lt;br&gt; {sub1=x; sub2=y;}&lt;br&gt;void put_marks()&lt;br&gt; {cout&amp;lt;&amp;lt;&amp;quot;Marks in subject 1: &amp;quot;&amp;lt;&amp;lt;sub1&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;Marks in subject 2: &amp;quot;&amp;lt;&amp;lt;sub2&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;  }&lt;br&gt;};&lt;br&gt;class sports&lt;br&gt;{protected:float score;&lt;br&gt;public:&lt;br&gt;void get_score(float s)&lt;br&gt; {score=s;}&lt;br&gt;void put_score()&lt;br&gt; {cout&amp;lt;&amp;lt;&amp;quot;Sports weightage: &amp;quot;&amp;lt;&amp;lt;score&amp;lt;&amp;lt;&amp;quot;\n\n&amp;quot;;}&lt;br&gt;};&lt;br&gt; class result:public test,public sports&lt;br&gt;{float total;&lt;br&gt;public:&lt;br&gt;void display();&lt;br&gt;};&lt;br&gt;void result::display()&lt;br&gt;{total=sub1+sub2+score;&lt;br&gt;put_num();&lt;br&gt;put_marks();&lt;br&gt;put_score();&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;Total Score: &amp;quot;&amp;lt;&amp;lt;total&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; }&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt;clrscr();&lt;br&gt;result s;&lt;br&gt;s.get_num(25);&lt;br&gt;s.get_marks(92.3,94.8);&lt;br&gt;s.get_score(7);&lt;br&gt;s.display();&lt;br&gt;getch();return 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4416338997415089524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/hybrid-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4416338997415089524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4416338997415089524'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/hybrid-inheritance.html' title='HYBRID INHERITANCE'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4003470236502286230</id><published>2011-12-26T19:05:00.001-08:00</published><updated>2011-12-26T19:05:59.518-08:00</updated><title type='text'>MULTILEVEL INHERITANCE</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;//Program to show multilevel inheritance&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;&lt;br&gt;class student&lt;br&gt;{&lt;br&gt; protected:&lt;br&gt; int roll_num;&lt;br&gt;  public:&lt;br&gt; void get_num(int a)&lt;br&gt; {&lt;br&gt;  roll_num=a;&lt;br&gt; }&lt;br&gt; void put_num()&lt;br&gt; {&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;Roll number: &amp;quot;&amp;lt;&amp;lt;roll_num&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt; class test:public student&lt;br&gt; {&lt;br&gt;   protected:&lt;br&gt;  float sub1;&lt;br&gt;  float sub2;&lt;br&gt;  public:&lt;br&gt;  void get_marks(float x,float y)&lt;br&gt;  {&lt;br&gt;    sub1=x;&lt;br&gt;    sub2=y;&lt;br&gt;  }&lt;br&gt;  void put_marks()&lt;br&gt;  {&lt;br&gt;    cout&amp;lt;&amp;lt;&amp;quot;Marks in sub1: &amp;quot;&amp;lt;&amp;lt;sub1&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;     cout&amp;lt;&amp;lt;&amp;quot;Marks in sub2: &amp;quot;&amp;lt;&amp;lt;sub2&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;  }&lt;br&gt; };&lt;br&gt;&lt;br&gt; class result:public test&lt;br&gt;{&lt;br&gt; float total;&lt;br&gt; public:&lt;br&gt; void display()&lt;br&gt; {&lt;br&gt;  total= sub1+sub2;&lt;br&gt;  put_num();&lt;br&gt;   put_marks();&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;Total: &amp;quot;&amp;lt;&amp;lt;total&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt; result s;&lt;br&gt; s.get_num(81);&lt;br&gt; s.get_marks(87.0,91.5);&lt;br&gt; s.display();&lt;br&gt; return 0;&lt;br&gt;}&lt;br&gt; &lt;br&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4003470236502286230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/multilevel-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4003470236502286230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4003470236502286230'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/multilevel-inheritance.html' title='MULTILEVEL INHERITANCE'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-7214357492734847616</id><published>2011-12-26T19:03:00.001-08:00</published><updated>2011-12-26T19:03:07.796-08:00</updated><title type='text'>MULTIPLE INHERITANCE</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;//Program to show multiple inheritance&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;class A&lt;br&gt;{&lt;br&gt; protected:&lt;br&gt; int a;&lt;br&gt; public:&lt;br&gt; void get_a(int x)&lt;br&gt;  {&lt;br&gt;  a=x;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt;class B&lt;br&gt;{&lt;br&gt; protected:&lt;br&gt; int b;&lt;br&gt; public:&lt;br&gt; void get_b(int y)&lt;br&gt; {&lt;br&gt;  b=y;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt;class C: public A,public B&lt;br&gt;{&lt;br&gt; public:&lt;br&gt; void display()&lt;br&gt; {&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;a= &amp;quot;&amp;lt;&amp;lt;a&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;   cout&amp;lt;&amp;lt;&amp;quot;b= &amp;quot;&amp;lt;&amp;lt;b&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;a*b= &amp;quot;&amp;lt;&amp;lt;a*b&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt; C c;&lt;br&gt; c.get_a(24);&lt;br&gt; c.get_b(5);&lt;br&gt; c.display();&lt;br&gt;  return 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/7214357492734847616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/multiple-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7214357492734847616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7214357492734847616'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/multiple-inheritance.html' title='MULTIPLE INHERITANCE'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-513414841137834503</id><published>2011-12-26T19:00:00.001-08:00</published><updated>2011-12-26T19:00:50.800-08:00</updated><title type='text'>SINGLE INHERITANCE</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;//Program to show single inheritance&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;class B&lt;br&gt;{&lt;br&gt; int a;&lt;br&gt; public:&lt;br&gt;  int b;&lt;br&gt; void input_ab()&lt;br&gt; {&lt;br&gt;  a=10;b=20;&lt;br&gt; }&lt;br&gt; int get_a()&lt;br&gt; {&lt;br&gt;  return a;&lt;br&gt; }&lt;br&gt; void display_a()&lt;br&gt; {&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;a= &amp;quot;&amp;lt;&amp;lt;a&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; }&lt;br&gt;};&lt;br&gt;&lt;br&gt;class D:public B&lt;br&gt; {&lt;br&gt; int c;&lt;br&gt; public:&lt;br&gt; void sum()&lt;br&gt; {&lt;br&gt;  c = b+get_a();&lt;br&gt; }&lt;br&gt;void display();&lt;br&gt;};&lt;br&gt;&lt;br&gt;void D :: display()&lt;br&gt;{&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;a= &amp;quot;&amp;lt;&amp;lt;get_a()&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;b= &amp;quot;&amp;lt;&amp;lt;b&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;  cout&amp;lt;&amp;lt;&amp;quot;c= &amp;quot;&amp;lt;&amp;lt;c&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt; D d;&lt;br&gt; d.input_ab();&lt;br&gt; d.get_a();&lt;br&gt; d.display();&lt;br&gt; d.b=30;&lt;br&gt; d.sum();&lt;br&gt; d.display();&lt;br&gt; return 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/513414841137834503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/single-inheritance.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/513414841137834503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/513414841137834503'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/single-inheritance.html' title='SINGLE INHERITANCE'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-8833474064969327261</id><published>2011-12-26T18:54:00.001-08:00</published><updated>2011-12-26T18:54:33.660-08:00</updated><title type='text'>Program to create a class city to store the details such as name, area, population, latitude, longitude of the city.</title><content type='html'>  &lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;span style&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;span style&gt; &lt;/span&gt;/*Create a class city to store the details such as name, area, population,&lt;br&gt; latitude, longitude of the city. Also,create functions to find neighbouring cities&lt;br&gt; having similar lattitudes and longitudes.*/&lt;br&gt; #include&amp;lt;iostream.h&amp;gt;&lt;br&gt; #include&amp;lt;conio.h&amp;gt;&lt;br&gt; #include&amp;lt;stdio.h&amp;gt;&lt;br&gt; class city&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt; {&lt;br&gt; char name[30];&lt;br&gt; float area;&lt;br&gt; int population;&lt;br&gt; float latitude, longitude;&lt;br&gt; public:&lt;br&gt; void getdata();&lt;br&gt; float getlatitude();&lt;br&gt; float getlongitude();&lt;br&gt; void putdata();&lt;br&gt; }c[2];&lt;br&gt; &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;void city::getdata()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;Enter The name of the city&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;name;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n Enter the area , population, latitude, longitude of the city&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;area;&lt;br&gt; cin&amp;gt;&amp;gt;population;&lt;br&gt; cin&amp;gt;&amp;gt;latitude;&lt;br&gt; cin&amp;gt;&amp;gt;longitude;&lt;br&gt; }&lt;br&gt; void city::putdata()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;name;&lt;br&gt; }&lt;br&gt; float city::getlatitude()&lt;br&gt; {&lt;br&gt; return(latitude);&lt;br&gt; }&lt;br&gt; float city::getlongitude()&lt;br&gt; {&lt;br&gt; return(longitude);&lt;br&gt; }&lt;br&gt; void find_similar_city()&lt;br&gt; {&lt;br&gt; int j,k;&lt;br&gt; float a,b,d,e;&lt;br&gt; for(j=0;j&amp;lt;2;j++)&lt;br&gt; {&lt;br&gt; for(k=j+1;k&amp;lt;2;k++)&lt;br&gt; a=c[j].getlatitude();&lt;br&gt; b=c[k].getlatitude();&lt;br&gt; d=c[j].getlongitude();&lt;br&gt; e=c[k].getlongitude();&lt;br&gt; if(a==b)&lt;br&gt; {cout&amp;lt;&amp;lt;&amp;quot;\n The cities &amp;quot;;&lt;br&gt; c[j].putdata();&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;and&amp;quot;;&lt;br&gt; c[k].putdata();&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;have same latitude&amp;quot;;}&lt;br&gt; else&lt;br&gt; if (d==e)&lt;br&gt; {cout&amp;lt;&amp;lt;&amp;quot;\n The cities &amp;quot;;&lt;br&gt; c[j].putdata();&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;and&amp;quot;;&lt;br&gt; c[k].putdata();&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;have same longitude&amp;quot;;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;margin-left:0in;line-height:normal;text-autospace:none&quot;&gt;&lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;}&lt;br&gt;  else continue;&lt;br&gt; } }&lt;br&gt; int main()&lt;br&gt; {&lt;br&gt; for(int i=0;i&amp;lt;2;i++)&lt;br&gt; {&lt;br&gt; c[i].getdata();&lt;br&gt; }&lt;br&gt; find_similar_city();&lt;br&gt; getch();&lt;br&gt; return 0;&lt;br&gt; }&lt;/span&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/8833474064969327261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-city-to-store.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/8833474064969327261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/8833474064969327261'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-city-to-store.html' title='Program to create a class city to store the details such as name, area, population, latitude, longitude of the city.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4333386629864195871</id><published>2011-12-26T18:48:00.001-08:00</published><updated>2011-12-26T18:48:25.814-08:00</updated><title type='text'>Program to create a class student to store the name,rollno and marks of the students in various subjects and calculate the average,percentage.</title><content type='html'>  &lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt; &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;/*Create a class student to store the name,rollno and marks of the students in various subjects,&lt;br&gt; create function to calculate the average percentage of the students and print whether the&lt;br&gt; student is pass or fail.( for n students.)*/&lt;br&gt; #include&amp;lt;iostream.h&amp;gt;&lt;br&gt; #include&amp;lt;conio.h&amp;gt;&lt;br&gt; #include&amp;lt;stdio.h&amp;gt;&lt;br&gt; #include&amp;lt;string.h&amp;gt;&lt;br&gt; class student&lt;br&gt; {&lt;br&gt; char name[30];&lt;br&gt; int rollno;&lt;br&gt; int marks[5];&lt;br&gt; public:&lt;br&gt; void getdata();&lt;br&gt; float calculate();&lt;br&gt; void result();&lt;br&gt; };&lt;br&gt; void student::getdata()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n enter the name of the student :&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;name;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n enter the roll number &amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;rollno;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n Now enter the marks in five subjects&amp;quot;;&lt;br&gt; for(int i=0;i&amp;lt;5;i++)&lt;br&gt; cin&amp;gt;&amp;gt;marks[i];&lt;br&gt; }&lt;br&gt; float student::calculate()&lt;br&gt; {&lt;br&gt; float avg=0.0;&lt;br&gt; float tot=0;&lt;br&gt; for(int i=0;i&amp;lt;5;i++)&lt;br&gt; tot+=marks[i];&lt;br&gt; avg=tot/5;&lt;br&gt; return(avg);&lt;br&gt; }&lt;br&gt; int main()&lt;br&gt; {&lt;br&gt; int n;&lt;br&gt; float perc;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;enter number of studnets&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;n;&lt;br&gt; student s[n];&lt;br&gt; for(int i=0;i&amp;lt;n;i++)&lt;br&gt; {&lt;br&gt; s[i].getdata();&lt;br&gt; perc=s[i].calculate();&lt;br&gt; if(perc&amp;gt;50)cout&amp;lt;&amp;lt;&amp;quot;\n PASS CONGRATULATIONS&quot;&lt;/span&gt;&lt;span style lang=&quot;EN&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;margin-left:0in;line-height:normal;text-autospace:none&quot;&gt; &lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;else&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n YOU ARE FAILED &lt;/span&gt;&lt;span style lang=&quot;EN&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&amp;quot;;&lt;br&gt; }&lt;br&gt; getch();&lt;br&gt; return 0;&lt;br&gt; }&lt;/span&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4333386629864195871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-student-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4333386629864195871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4333386629864195871'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-student-to.html' title='Program to create a class student to store the name,rollno and marks of the students in various subjects and calculate the average,percentage.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-8373708600058321739</id><published>2011-12-26T18:31:00.001-08:00</published><updated>2011-12-26T18:31:37.809-08:00</updated><title type='text'>Program to create a class time to add two times in hours and minutes.</title><content type='html'>  &lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;span style=&quot;font-size:12pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;span&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot; target=&quot;_blank&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;margin-left:0in;line-height:normal;text-autospace:none&quot;&gt;&lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;//Program  to create a class time to add two times in hours and minutes.&lt;br&gt; #include&amp;lt;iostream.h&amp;gt;&lt;br&gt; #include&amp;lt;stdio.h&amp;gt;&lt;br&gt; #include&amp;lt;conio.h&amp;gt;&lt;br&gt; class addtime&lt;br&gt; {&lt;br&gt; int hours;&lt;br&gt; int minutes;&lt;br&gt; public:&lt;br&gt; addtime()&lt;br&gt; {}&lt;br&gt; addtime(int t)&lt;br&gt; {&lt;br&gt; hours=t/60;&lt;br&gt; minutes=t%60;&lt;br&gt; }&lt;br&gt; addtime operator +(addtime t1);&lt;br&gt; void show()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;The time added is :&amp;quot;&amp;lt;&amp;lt;hours&amp;lt;&amp;lt;&amp;quot;.&amp;quot;&amp;lt;&amp;lt;minutes;&lt;br&gt; }&lt;br&gt; };&lt;br&gt; addtime addtime::operator +(addtime t)&lt;br&gt; {&lt;br&gt; addtime temp;&lt;br&gt; temp.hours = hours+ t.hours;&lt;br&gt; temp.minutes= minutes+ t.minutes;&lt;br&gt; return(temp);&lt;br&gt; }&lt;br&gt; int main()&lt;br&gt; { int a,b;&lt;br&gt; addtime t1,t2,t3;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;TIME ADDITION USING OPERATOR OVERLOADING: &amp;quot;;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n enter the times to be added&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;a&amp;gt;&amp;gt;b;&lt;br&gt; t1=addtime(a);&lt;br&gt; t2=addtime(b);&lt;br&gt; t3=t1 +t2;&lt;br&gt; t3.show();&lt;br&gt; getch();&lt;br&gt; return 0;&lt;br&gt; }&lt;br&gt; &lt;br&gt; &lt;/span&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/8373708600058321739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-time-to-add-two.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/8373708600058321739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/8373708600058321739'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-to-create-class-time-to-add-two.html' title='Program to create a class time to add two times in hours and minutes.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-2959457337260955275</id><published>2011-12-26T18:03:00.001-08:00</published><updated>2011-12-26T18:03:26.299-08:00</updated><title type='text'>program on employee salary details.</title><content type='html'>&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;font&gt;&lt;span style=&quot;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;font&gt;&lt;span style=&quot;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt; &lt;font&gt;&lt;span style=&quot;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;/*Create a class employee to store the personal and salary details. Make functions to enter and show the employee details. Also create a function to calculate the net salary of an employee. given HRA=5%of base salary, PF=7% of base salary and TAX=10% if salary &amp;lt; 2 lakh P.A. or 15% if salary&amp;gt;2Lakh per annum&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;font&gt;&lt;b&gt;Health Reimbursement Accounts&lt;/b&gt; or &lt;b&gt;Health Reimbursement Arrangements (HRAs)&lt;/b&gt; are sanctioned programs that allow an employer to set aside funds to  reimburse medical expenses paid by participating employees.&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt;&lt;font&gt;PF:PROVIDENT FUND*/&lt;/font&gt;&lt;/p&gt;#Include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;  &lt;span style=&quot;font-size:12.0pt;font-family:&amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;&quot;&gt;&lt;font&gt; #include&amp;lt;stdio.h&amp;gt;&lt;br&gt; class employee&lt;br&gt; {&lt;br&gt; char name[30];&lt;br&gt; int age;&lt;br&gt; float basic,hra,pf,tax,sal;&lt;br&gt; public:&lt;br&gt; void get();&lt;br&gt; void pay_sal();&lt;br&gt; void put();&lt;br&gt; };&lt;br&gt; //class employee&lt;br&gt; void employee::get()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;Enter the name of the employee&amp;quot;;&lt;br&gt; gets(name);&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n Enter the age of the employee&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;age;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n Enter the basic salary per month&amp;quot;;&lt;br&gt; cin&amp;gt;&amp;gt;basic;&lt;br&gt; }&lt;br&gt; void employee::pay_sal()&lt;br&gt; {&lt;br&gt; pf=0.07*basic;&lt;br&gt; hra=.05*basic;&lt;br&gt; if((12*basic)&amp;gt;200000)&lt;br&gt; tax=.1*basic;&lt;br&gt; else&lt;br&gt; tax=.15*basic;&lt;br&gt; sal=(12*basic+hra+pf-tax);&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\nNet annual income:&amp;quot;&amp;lt;&amp;lt;sal;&lt;br&gt; }&lt;br&gt; void employee::put()&lt;br&gt; {&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;Employee Details&amp;quot;;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n NAME&amp;quot;;&lt;br&gt; puts(name);&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\n AGE&amp;quot;&amp;lt;&amp;lt;age;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\nNet salary&amp;quot;&amp;lt;&amp;lt;sal;&lt;br&gt; }&lt;br&gt; int main()&lt;br&gt; {&lt;br&gt; employee e;&lt;br&gt; e.get();&lt;br&gt; e.pay_sal();&lt;br&gt; e.put();&lt;br&gt; getch();&lt;br&gt; return 0;&lt;br&gt; }&lt;/font&gt;&lt;/span&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin:5pt 0in;line-height:normal&quot;&gt; &lt;font&gt;&lt;br&gt;   &lt;/font&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/2959457337260955275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-on-employee-salary-details.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2959457337260955275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2959457337260955275'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/program-on-employee-salary-details.html' title='program on employee salary details.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-6207550298908523518</id><published>2011-12-26T17:38:00.001-08:00</published><updated>2011-12-26T17:38:54.734-08:00</updated><title type='text'>ROMAN NUMBER TO DECIMAL</title><content type='html'>&lt;div class=&quot;gmail_quote&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;  &lt;div class=&quot;gmail_quote&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt; &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;/*C++ Program to convert a Roman numeral to its decimal equivalent.*/&lt;/span&gt;&lt;/b&gt;   &lt;/p&gt;&lt;div class=&quot;im&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;int *a,len,i,j,k;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;char *rom;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;Enter the Roman Numeral : &quot;;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; gets(rom);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;div class=&quot;h5&quot;&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;len=strlen(rom);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;for(i=0;i&amp;lt;len;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;if(rom[i]==&#39;I&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;a[i]=1;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;V&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=5;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;X&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=10;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;L&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=50;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;C&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=100;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;D&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=500;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(rom[i]==&#39;M&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;a[i]=1000;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;\nInvalid Value&quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;exit(0);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;k=a[len-1];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;for(i=len-1;i&amp;gt;0;i–-)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;if(a[i]&amp;gt;a[i-1])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;k=k-a[i-1];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;  &lt;/span&gt;else if(a[i]==a[i-1] || a[i]&amp;lt;a[i-1])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt;   &lt;/span&gt;k=k+a[i-1];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;cout&amp;lt;&amp;lt;&quot;\nIts Decimal Equivalent is : &quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;cout&amp;lt;&amp;lt;k;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;span&gt; &lt;/span&gt;getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/6207550298908523518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/roman-number-to-decimal_3816.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/6207550298908523518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/6207550298908523518'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/roman-number-to-decimal_3816.html' title='ROMAN NUMBER TO DECIMAL'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-2242315721081391591</id><published>2011-12-26T17:28:00.001-08:00</published><updated>2011-12-26T17:28:41.693-08:00</updated><title type='text'>C++ program on arithmetic operations on complex number</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot; target=&quot;_blank&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;/*C++ Program that uses functions to perform the following operations using structures:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;i) Reading a complex number&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;ii) Writing a complex number&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;iii) Addition of two complex numbers&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;iv) Multiplication of two complex numbers*/&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;#include&amp;lt;math.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;void arithmetic(int opern);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;struct comp&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;double realpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;double imgpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;};&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;int opern;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n\n \t\t\t***** MAIN MENU *****&quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n\n Select your option: \n 1 : ADD\n 2 : MULTIPLY\n 0 : EXIT \n\n\t\t Enter your Option [&lt;span&gt;  &lt;/span&gt;]\b\b&quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cin&amp;gt;&amp;gt;opern;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;switch(opern)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;case 0:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;exit(0);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;case 1:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;case 2:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;arithmetic(opern);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;default:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;main();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;}}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;void arithmetic(int opern)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;struct comp w1, w2, w;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n Enter two Complex Numbers&lt;span&gt;  &lt;/span&gt;(x+iy):\n Real Part of First Number:&quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cin&amp;gt;&amp;gt;w1.realpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n Imaginary Part of First Number : &quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cin&amp;gt;&amp;gt;w1.imgpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n Real Part of Second Number : &quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cin&amp;gt;&amp;gt;w2.realpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n Imaginary Part of Second Number : &quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cin&amp;gt;&amp;gt;w2.imgpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;switch(opern)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;/*addition of complex number*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;case 1:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;w.realpart = w1.realpart+w2.realpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;w.imgpart = w1.imgpart+w2.imgpart;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;/*multiplication of complex number*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;case 2:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;w.realpart=(w1.realpart*w2.realpart)-(w1.imgpart*w2.imgpart);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;w.imgpart=(w1.realpart*w2.imgpart)+(w1.imgpart*w2.realpart);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;cout&amp;lt;&amp;lt;&quot;\n Answer = &quot;&amp;lt;&amp;lt;w.realpart&amp;lt;&amp;lt;w.imgpart;&lt;/span&gt;&lt;/p&gt;      &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;main();//to ask user again and again .&lt;br&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family:&amp;quot;Lucida Console&amp;quot;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/2242315721081391591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/c-program-on-arithmetic-operations-on_26.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2242315721081391591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/2242315721081391591'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/12/c-program-on-arithmetic-operations-on_26.html' title='C++ program on arithmetic operations on complex number'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4322758105576936412</id><published>2011-11-10T18:46:00.001-08:00</published><updated>2011-11-10T18:46:58.887-08:00</updated><title type='text'>2&#39;s complement</title><content type='html'>&lt;div&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;/*program to find 2&amp;#39;s complement*/&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;process.h&amp;gt;&lt;br&gt; int main()&lt;br&gt;{&lt;/div&gt;&lt;p&gt;int i,a[20],z,n;&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;Enter the number of bits&amp;lt;20\n&amp;quot;;&lt;br&gt;cin&amp;gt;&amp;gt;n;&lt;/p&gt;&lt;p&gt;cout&amp;lt;&amp;lt;&amp;quot;Enter the binary no.\n&amp;quot;;&lt;br&gt;for(i=0;i&amp;lt;n;i++)&lt;br&gt;cin&amp;gt;&amp;gt;a[i];&lt;br&gt;for(i=0;i&amp;lt;n;i++)&lt;br&gt; {&lt;br&gt;if(a[i]==0)&lt;br&gt;{&lt;br&gt;a[i]=1;&lt;br&gt;}&lt;br&gt;else&lt;br&gt;{&lt;br&gt;a[i]=0;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;for(i=n-1;i&amp;gt;=0;i++)&lt;br&gt;{&lt;br&gt;if(a[i]==0)&lt;br&gt;{&lt;br&gt;a[i]=1;&lt;br&gt;break;&lt;br&gt;}&lt;br&gt;else&lt;br&gt;{&lt;br&gt;a[i]=0;&lt;br&gt;}&lt;br&gt;}&lt;/p&gt;&lt;p&gt;cout&amp;lt;&amp;lt;&amp;quot;The 2&amp;#39;s complement is : &amp;quot;;&lt;br&gt; for(i=0;i&amp;lt;n;i++)&lt;br&gt;{&lt;br&gt;cout&amp;lt;&amp;lt;a[i];&lt;br&gt;}&lt;/p&gt;&lt;p&gt;getch();&lt;br&gt;return 0;&lt;br&gt;}&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4322758105576936412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/2s-complement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4322758105576936412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4322758105576936412'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/2s-complement.html' title='2&#39;s complement'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-1870128469259146036</id><published>2011-11-10T18:41:00.001-08:00</published><updated>2011-11-10T18:41:32.754-08:00</updated><title type='text'>Virtual base classes</title><content type='html'>&lt;div&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;/*Program to illustrate virtual base classes*/&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;class student&lt;br&gt;{&lt;br&gt;protected:&lt;br&gt;int roll;&lt;br&gt; public:&lt;br&gt;void getnumber(int a)&lt;br&gt;{&lt;br&gt;roll=a;&lt;br&gt;}&lt;br&gt;void putnumber()&lt;br&gt;{&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\nRoll no.:&amp;quot;&amp;lt;&amp;lt;roll&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;}&lt;/div&gt;&lt;p&gt;};&lt;br&gt;class test:virtual public student&lt;br&gt;{&lt;br&gt;protected:&lt;br&gt; float part1,part2;&lt;br&gt;public:&lt;br&gt;void getmarks(float x,float y)&lt;br&gt;{&lt;br&gt;part1=x;&lt;br&gt;part2=y;&lt;br&gt;}&lt;br&gt;void putmarks()&lt;br&gt;{&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\n Marks obtained\n&amp;quot;;&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;Part1: &amp;quot;&amp;lt;&amp;lt;part1&amp;lt;&amp;lt;endl;&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;Part2: &amp;quot;&amp;lt;&amp;lt;part2;&lt;br&gt;}&lt;/p&gt;&lt;p&gt;};&lt;br&gt;class sports: public virtual student&lt;br&gt;{&lt;br&gt;protected:&lt;br&gt;float score;&lt;br&gt;public:&lt;br&gt;void getscore(float s)&lt;br&gt;{&lt;br&gt;score=s;&lt;br&gt;}&lt;br&gt;void putscore()&lt;br&gt;{&lt;br&gt; cout&amp;lt;&amp;lt;&amp;quot;\nSports wt: &amp;quot;&amp;lt;&amp;lt;score&amp;lt;&amp;lt;endl;&lt;br&gt;}&lt;br&gt;};&lt;br&gt;class result:public test,public sports&lt;br&gt;{&lt;br&gt;float total;&lt;br&gt;public:&lt;br&gt;void display()&lt;br&gt;{&lt;br&gt;total= part1+part2+score;&lt;br&gt;putnumber();&lt;br&gt;putmarks();&lt;br&gt; putscore();&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\ntotal score: &amp;quot;&amp;lt;&amp;lt;total&amp;lt;&amp;lt;endl;&lt;br&gt;}&lt;br&gt;};&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt;result student1;&lt;br&gt;student1.getnumber(678);&lt;br&gt;student1.getmarks(30.5,25.5);&lt;br&gt;student1.getscore(7.0);&lt;br&gt; student1.display();&lt;br&gt;return 0;&lt;br&gt;}&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/1870128469259146036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/virtual-base-classes_10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/1870128469259146036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/1870128469259146036'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/virtual-base-classes_10.html' title='Virtual base classes'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-764917830474523769</id><published>2011-11-10T18:34:00.001-08:00</published><updated>2011-11-10T18:34:51.714-08:00</updated><title type='text'>THIS pointer</title><content type='html'>&lt;div&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;/*program to illustrate this pointer*/&lt;br&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;#include&amp;lt;string.h&amp;gt;&lt;br&gt; class person&lt;br&gt;{&lt;br&gt;char name[20];&lt;br&gt;float age;&lt;br&gt;public:&lt;br&gt;person(char *s,float a)&lt;br&gt;{&lt;br&gt;strcpy(name,s);&lt;br&gt;age=a;&lt;br&gt;}&lt;br&gt;person &amp;amp;person::greater(person &amp;amp;x )&lt;br&gt;{&lt;br&gt;if(x.age&amp;gt;age)&lt;br&gt;{&lt;br&gt;return x;&lt;br&gt;}&lt;br&gt; else&lt;br&gt;{&lt;br&gt; return *this;&lt;br&gt;}&lt;br&gt;}&lt;br&gt;void display()&lt;br&gt;{&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\nName: &amp;quot;&amp;lt;&amp;lt;name&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\nAge: &amp;quot;&amp;lt;&amp;lt;age;&lt;br&gt;}&lt;br&gt;};&lt;br&gt;int main()&lt;br&gt;{&lt;br&gt;person p1(&amp;quot;John&amp;quot;,37.50),p2(&amp;quot;Ahmed&amp;quot;,29.0),p3(&amp;quot;hebber&amp;quot;,40.25);&lt;br&gt; person p=p1.greater(p3);&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\nElder person is: &amp;quot;;&lt;br&gt;p.display();&lt;br&gt;p=p1.greater(p2);&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\nElder person is: &amp;quot;;&lt;br&gt;p.display();&lt;br&gt;return 0;&lt;br&gt;}&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/764917830474523769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/this-pointer_10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/764917830474523769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/764917830474523769'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/this-pointer_10.html' title='THIS pointer'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4977853915354109249</id><published>2011-11-10T18:23:00.000-08:00</published><updated>2013-12-05T21:26:23.915-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="c++ programs"/><category scheme="http://www.blogger.com/atom/ns#" term="polymorphism"/><category scheme="http://www.blogger.com/atom/ns#" term="runtime"/><category scheme="http://www.blogger.com/atom/ns#" term="runtime polymorphism"/><title type='text'>Runtime polymorphism</title><content type='html'>&lt;div&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;/*program to illustrate run time polymorphism*/&lt;/div&gt;&lt;div&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br /&gt;#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;#include&amp;lt;string.h&amp;gt;&lt;br /&gt; class media&lt;br /&gt;{&lt;br /&gt;  protected:&lt;br /&gt;      char title[50];&lt;br /&gt;      float price;&lt;br /&gt;  public: media(char *s,float a)&lt;br /&gt;         {&lt;br /&gt;   strcpy(title,s);&lt;br /&gt;   price=a;&lt;br /&gt;         }&lt;br /&gt;   virtual void display(){}&lt;br /&gt;};&lt;br /&gt; class book:public media&lt;br /&gt;{&lt;br /&gt;      int pages;&lt;br /&gt;      public:&lt;br /&gt;      book(char *s,float a,int p):media(s,a)&lt;br /&gt;      {&lt;br /&gt;       pages =p;&lt;br /&gt;      }&lt;br /&gt;     void display();&lt;br /&gt;};&lt;br /&gt;class tape:public media&lt;br /&gt;{&lt;br /&gt;      float time;&lt;br /&gt;     public:&lt;br /&gt;     tape(char *s,float a,float t):media(s,a)&lt;br /&gt;     {&lt;br /&gt;             time=t;&lt;br /&gt;            }&lt;br /&gt;                   void display();&lt;br /&gt;};&lt;br /&gt;     void book::display()&lt;br /&gt;         {&lt;br /&gt;    cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;&amp;lt;&amp;lt;title;&lt;br /&gt;   cout&amp;lt;&amp;lt;&amp;quot;\npages: &amp;quot;&amp;lt;&amp;lt;pages;&lt;br /&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;&amp;lt;&amp;lt;price;&lt;br /&gt;  }&lt;br /&gt;     void tape::display()&lt;br /&gt;         {&lt;br /&gt;          cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;&amp;lt;&amp;lt;title;&lt;br /&gt;    cout&amp;lt;&amp;lt;&amp;quot;\nplay time: &amp;quot;&amp;lt;&amp;lt;time&amp;lt;&amp;lt;&amp;quot;mins&amp;quot;;&lt;br /&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;&amp;lt;&amp;lt;price;&lt;br /&gt;  }&lt;br /&gt;   int main()&lt;br /&gt;                 {&lt;br /&gt;                     char *title=new char[30];&lt;br /&gt;                      float price,time;&lt;br /&gt;                     int pages;                   &lt;br /&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\nEnter the book details\n&amp;quot;;&lt;br /&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;;&lt;br /&gt;                      cin&amp;gt;&amp;gt;title;&lt;br /&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\npages: &amp;quot;;&lt;br /&gt;                     cin&amp;gt;&amp;gt;pages;&lt;br /&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;;&lt;br /&gt;                     cin&amp;gt;&amp;gt;price;&lt;br /&gt;                      book book1(title ,price ,pages);&lt;br /&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nEnter the tape details\n&amp;quot;;&lt;br /&gt;       cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;;&lt;br /&gt;       cin&amp;gt;&amp;gt;title;&lt;br /&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nplay time in min: &amp;quot;;&lt;br /&gt;        cin&amp;gt;&amp;gt;time;&lt;br /&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;;&lt;br /&gt;       cin&amp;gt;&amp;gt;price;&lt;br /&gt;       tape tape1(title,price,time);&lt;br /&gt;       media *list[2];&lt;br /&gt;       list[0]=&amp;amp;book1;&lt;br /&gt;       list[1]=&amp;amp;tape1;&lt;/div&gt; &lt;p&gt;cout&amp;lt;&amp;lt;&amp;quot;\nmedia details&amp;quot;;&lt;br /&gt;cout&amp;lt;&amp;lt;&amp;quot;\n....book....&amp;quot;;&lt;br /&gt;list[0]-&amp;gt;display();&lt;br /&gt;cout&amp;lt;&amp;lt;&amp;quot;\n....tape....&amp;quot;;&lt;br /&gt;list[1]-&amp;gt;display();&lt;br /&gt;getch();return 0;&lt;br /&gt; }&lt;/p&gt; </content><link rel="related" href="codingdatastructure.blogspot.com" title="Runtime polymorphism"/><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4977853915354109249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/runtime-polymorphism_10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4977853915354109249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4977853915354109249'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/runtime-polymorphism_10.html' title='Runtime polymorphism'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-5452794182552250690</id><published>2011-11-10T18:14:00.001-08:00</published><updated>2011-11-10T18:14:56.110-08:00</updated><title type='text'>RUNTIME POLYMORPHISM</title><content type='html'>&lt;div&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/div&gt;&lt;div&gt;/*program to illustrate run time polymorphism*/&lt;/div&gt;&lt;div&gt;#include&amp;lt;iostream.h&amp;gt;&lt;br&gt;#include&amp;lt;conio.h&amp;gt;&lt;br&gt;#include&amp;lt;string.h&amp;gt;&lt;br&gt; class media&lt;br&gt;{&lt;br&gt;  protected:&lt;br&gt;      char title[50];&lt;br&gt;      float price;&lt;br&gt;  public: media(char *s,float a)&lt;br&gt;         {&lt;br&gt;   strcpy(title,s);&lt;br&gt;   price=a;&lt;br&gt;         }&lt;br&gt;   virtual void display(){}&lt;br&gt;};&lt;br&gt; class book:public media&lt;br&gt;{&lt;br&gt;      int pages;&lt;br&gt;      public:&lt;br&gt;      book(char *s,float a,int p):media(s,a)&lt;br&gt;      {&lt;br&gt;       pages =p;&lt;br&gt;      }&lt;br&gt;     void display();&lt;br&gt;};&lt;br&gt;class tape:public media&lt;br&gt;{&lt;br&gt;      float time;&lt;br&gt;     public:&lt;br&gt;     tape(char *s,float a,float t):media(s,a)&lt;br&gt;     {&lt;br&gt;             time=t;&lt;br&gt;            }&lt;br&gt;                   void display();&lt;br&gt;};&lt;br&gt;     void book::display()&lt;br&gt;         {&lt;br&gt;    cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;&amp;lt;&amp;lt;title;&lt;br&gt;   cout&amp;lt;&amp;lt;&amp;quot;\npages: &amp;quot;&amp;lt;&amp;lt;pages;&lt;br&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;&amp;lt;&amp;lt;price;&lt;br&gt;  }&lt;br&gt;     void tape::display()&lt;br&gt;         {&lt;br&gt;          cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;&amp;lt;&amp;lt;title;&lt;br&gt;    cout&amp;lt;&amp;lt;&amp;quot;\nplay time: &amp;quot;&amp;lt;&amp;lt;time&amp;lt;&amp;lt;&amp;quot;mins&amp;quot;;&lt;br&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;&amp;lt;&amp;lt;price;&lt;br&gt;  }&lt;br&gt;   int main()&lt;br&gt;                 {&lt;br&gt;                     char *title=new char[30];&lt;br&gt;                      float price,time;&lt;br&gt;                     int pages;                   &lt;br&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\nEnter the book details\n&amp;quot;;&lt;br&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;;&lt;br&gt;                      cin&amp;gt;&amp;gt;title;&lt;br&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\npages: &amp;quot;;&lt;br&gt;                     cin&amp;gt;&amp;gt;pages;&lt;br&gt;                     cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;;&lt;br&gt;                     cin&amp;gt;&amp;gt;price;&lt;br&gt;                      book book1(title ,price ,pages);&lt;br&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nEnter the tape details\n&amp;quot;;&lt;br&gt;       cout&amp;lt;&amp;lt;&amp;quot;\ntitle: &amp;quot;;&lt;br&gt;       cin&amp;gt;&amp;gt;title;&lt;br&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nplay time in min: &amp;quot;;&lt;br&gt;        cin&amp;gt;&amp;gt;time;&lt;br&gt;       cout&amp;lt;&amp;lt;&amp;quot;\nprice: &amp;quot;;&lt;br&gt;       cin&amp;gt;&amp;gt;price;&lt;br&gt;       tape tape1(title,price,time);&lt;br&gt;       media *list[2];&lt;br&gt;       list[0]=&amp;amp;book1;&lt;br&gt;       list[1]=&amp;amp;tape1;&lt;/div&gt; &lt;p&gt;cout&amp;lt;&amp;lt;&amp;quot;\nmedia details&amp;quot;;&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\n....book....&amp;quot;;&lt;br&gt;list[0]-&amp;gt;display();&lt;br&gt;cout&amp;lt;&amp;lt;&amp;quot;\n....tape....&amp;quot;;&lt;br&gt;list[1]-&amp;gt;display();&lt;br&gt;getch();return 0;&lt;br&gt; }&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/5452794182552250690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/runtime-polymorphism.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/5452794182552250690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/5452794182552250690'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/runtime-polymorphism.html' title='RUNTIME POLYMORPHISM'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-3618733489782805921</id><published>2011-11-06T23:29:00.001-08:00</published><updated>2011-11-06T23:29:01.280-08:00</updated><title type='text'>Template based program to determine if a particular value occurs in an array of values.</title><content type='html'>&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Template based program that determines if a&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;particular value occurs in an array of values.*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;template &amp;lt;class T&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void search(T arr[])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{   T a;int flag=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     cout&amp;lt;&amp;lt;&amp;quot;Enter the element which you want to search:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     cin&amp;gt;&amp;gt;a;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     for(T i=0;i&amp;lt;10;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;               if(a==arr[i])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;               {flag=1;break;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     if(flag==1) cout&amp;lt;&amp;lt;&amp;quot;\nElement is present in the array.&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     else cout&amp;lt;&amp;lt;&amp;quot;\nElement is not present in the array.&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{     clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      int arri[10],ch,i;char arrc[11];float arrf[10];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;Program to search element in an array.\nWhich array you want to make?\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;Enter your choice:\n1.integer\n2.characters\n3.Real number\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cin&amp;gt;&amp;gt;ch;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      switch(ch)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             case 1: cout&amp;lt;&amp;lt;&amp;quot;Enter array of 10 integers:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         for(i=0;i&amp;lt;10;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                          cin&amp;gt;&amp;gt;arri[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         search(arri);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             case 2: cout&amp;lt;&amp;lt;&amp;quot;Enter array of 10 characters:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         for(i=0;i&amp;lt;10;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                          cin&amp;gt;&amp;gt;arrc[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         search(arrc);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             case 3: cout&amp;lt;&amp;lt;&amp;quot;Enter array of 10 real no.:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         for(i=0;i&amp;lt;10;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                          cin&amp;gt;&amp;gt;arrf[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         search(arrf);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                         break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             default:cout&amp;lt;&amp;lt;&amp;quot;WRONG CHOICE...!!&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/3618733489782805921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/template-based-program-to-determine-if.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/3618733489782805921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/3618733489782805921'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/template-based-program-to-determine-if.html' title='Template based program to determine if a particular value occurs in an array of values.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-7426038337378451612</id><published>2011-11-06T23:27:00.001-08:00</published><updated>2011-11-06T23:27:24.366-08:00</updated><title type='text'>To count the characters,lines and words in the text file</title><content type='html'>&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program to that counts the characters,&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;lines and words in the text file.*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;fstream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    char s;int w,c,l;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    w=c=l=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    fstream f;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    f.open(&amp;quot;E:\\count1.txt&amp;quot;,ios::in|ios::out);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    cout&amp;lt;&amp;lt;&amp;quot;Write a small paragraph:(Enter 0 in a new line to terminate)\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    while((s=getchar())!=&amp;#39;0&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    {f&amp;lt;&amp;lt;s;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    f.seekg(0);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    f.get(s);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    while(!f.eof())&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     if(s==&amp;#39; &amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     w++;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     else if(s==&amp;#39;\n&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             { l++;w++; }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     else c++;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     f.get(s);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;cout&amp;lt;&amp;lt;&amp;quot;\nNumber of characters:&amp;quot;&amp;lt;&amp;lt;c;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;cout&amp;lt;&amp;lt;&amp;quot;\nNo. of lines:&amp;quot;&amp;lt;&amp;lt;l;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;cout&amp;lt;&amp;lt;&amp;quot;\nNo of words:&amp;quot;&amp;lt;&amp;lt;w;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;f.close();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/7426038337378451612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-count-characterslines-and-words-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7426038337378451612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7426038337378451612'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-count-characterslines-and-words-in.html' title='To count the characters,lines and words in the text file'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-5342952305934309661</id><published>2011-11-06T23:25:00.001-08:00</published><updated>2011-11-06T23:25:46.570-08:00</updated><title type='text'>To delete all duplicate characters in the given string.</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;div&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program that uses a function to delete all&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;duplicate characters in the given string.*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{     clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      char str[30],str1[30];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      int flag,k=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;Enter a string:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      gets(str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      for(int i=0;str[i]!=&amp;#39;\0&amp;#39;;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      { flag=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            for(int j=i-1;j&amp;gt;=0;j--)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             if(str[i]==str[j])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;              {flag=1;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             if(flag==0){ str1[k]=str[i];str1[++k]=&amp;#39;\0&amp;#39;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;\nAfter removing duplicate characters string is &amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      for( k=0;str1[k]!=&amp;#39;\0&amp;#39;;k++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;str1[k];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/5342952305934309661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-delete-all-duplicate-characters-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/5342952305934309661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/5342952305934309661'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-delete-all-duplicate-characters-in.html' title='To delete all duplicate characters in the given string.'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-193252153124911443</id><published>2011-11-06T23:24:00.001-08:00</published><updated>2011-11-06T23:24:25.950-08:00</updated><title type='text'>To find largest,smallest number and sort given numbers using template function</title><content type='html'>&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program to find largest,smallest number and&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;sort given numbers using template function*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;template&amp;lt;class T&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void larsmal(T *no,int n)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{T temp;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; for(int i=1;i&amp;lt;n;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  for(int j=0;j&amp;lt;i;j++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   if(no[j]&amp;gt;no[i])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   temp=no[j];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   no[j]=no[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   no[i]=temp;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;&amp;quot;After Sorting:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;&amp;lt;&amp;lt;no[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nLargest no is &amp;quot;&amp;lt;&amp;lt;no[n-1];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;&amp;quot;\nSmallest no is &amp;quot;&amp;lt;&amp;lt;no[0];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   delete []no;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      int n,ch;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;How many numbers you want to Enter?\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cin&amp;gt;&amp;gt;n;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cout&amp;lt;&amp;lt;&amp;quot;Enter your choice:\n1.integer\n2.Real number\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      cin&amp;gt;&amp;gt;ch;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      switch(ch)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             case 1:int *noi=new int[50];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cout&amp;lt;&amp;lt;&amp;quot;Enter array of n integers:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cout&amp;lt;&amp;lt;&amp;quot;\nEnter the terms:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        for(int i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cin&amp;gt;&amp;gt;noi[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        larsmal(noi,n);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             case 2:float *nof=new float[50];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cout&amp;lt;&amp;lt;&amp;quot;Enter array of n real no.:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cout&amp;lt;&amp;lt;&amp;quot;\nEnter the terms:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        cin&amp;gt;&amp;gt;nof[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        larsmal(nof,n);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                        break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             default:cout&amp;lt;&amp;lt;&amp;quot;WRONG CHOICE...!!&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;             }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/193252153124911443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-find-largestsmallest-number-and-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/193252153124911443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/193252153124911443'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-find-largestsmallest-number-and-sort.html' title='To find largest,smallest number and sort given numbers using template function'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-4428678846683080323</id><published>2011-11-06T23:22:00.001-08:00</published><updated>2011-11-06T23:22:15.504-08:00</updated><title type='text'>To show a reversed string</title><content type='html'>&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program to  show a reversed string*/&lt;/span&gt;&lt;/p&gt;   &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void revstr(char ch[])&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{ int l=strlen(ch);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cout&amp;lt;&amp;lt;&amp;quot;\nReversed string:\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  for(int i=l-1;i&amp;gt;=0;i--)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cout&amp;lt;&amp;lt;ch[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; char ch[20];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; cout&amp;lt;&amp;lt;&amp;quot;Enter a string:\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; gets(ch);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; revstr(ch);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/4428678846683080323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-show-reversed-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4428678846683080323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/4428678846683080323'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/to-show-reversed-string.html' title='To show a reversed string'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-7192443369911839550</id><published>2011-11-06T23:19:00.001-08:00</published><updated>2011-11-06T23:19:58.287-08:00</updated><title type='text'>Pyramid of numbers</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;div&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Pyramid of numbers&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      1&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;     2 2&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;    3 3 3&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   4 4 4 4&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  5 5 5 5 5&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; 6 6 6 6 6 6 and so on&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{ clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  int n;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cout&amp;lt;&amp;lt;&amp;quot;Enter the value of n:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cin&amp;gt;&amp;gt;n;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  for(int i=0;i&amp;lt;=n;i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   for(int k=n;k&amp;gt;=i;k--)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   for(int j=0;j&amp;lt;i;j++)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;i&amp;lt;&amp;lt;&amp;quot; &amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;&amp;quot;\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/7192443369911839550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/pyramid-of-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7192443369911839550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7192443369911839550'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/pyramid-of-numbers.html' title='Pyramid of numbers'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-239491752023238466</id><published>2011-11-06T23:18:00.001-08:00</published><updated>2011-11-06T23:18:36.631-08:00</updated><title type='text'>Insert,delete a substring from a given position of mainstring</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;div&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program to insert,delete a substring from&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;a given position of mainstring*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void delstr(char *str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void insstr(char *str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            int ch;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            char *str;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            cout&amp;lt;&amp;lt;&amp;quot;Enter a string:\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            gets(str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            cout&amp;lt;&amp;lt;&amp;quot;\nPress 0 to delete some part of string.\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            cout&amp;lt;&amp;lt;&amp;quot;Press 1 to enter some part into the string.\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            cout&amp;lt;&amp;lt;&amp;quot;Enter your choice.\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            cin&amp;gt;&amp;gt;ch;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            switch(ch)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;              case 0: delstr(str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                          break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;              case 1: insstr(str);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;                          break;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;              default: cout&amp;lt;&amp;lt;&amp;quot;Wrong Choice...Sorry..!!&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void delstr(char *str)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{ int pos,n,i=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cout&amp;lt;&amp;lt;&amp;quot;\nEnter the position no. after which you want to delete the string.\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cin&amp;gt;&amp;gt;pos;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cout&amp;lt;&amp;lt;&amp;quot;Enter the no of characters you want to delete.\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  cin&amp;gt;&amp;gt;n;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  while(str[i]!=&amp;#39;\0&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  {if(i&amp;lt;(pos-1) || i&amp;gt;=(pos+n-1))&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   cout&amp;lt;&amp;lt;str[i];&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;   i++;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void insstr(char *str)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{int pos,n,i=0,j=0;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; char *substr;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; cout&amp;lt;&amp;lt;&amp;quot;\nEnter the position after which you want to insert the string:\n&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; cin&amp;gt;&amp;gt;pos;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; cout&amp;lt;&amp;lt;&amp;quot;Enter the string:&amp;quot;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; gets(substr);&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; while(str[i]!=&amp;#39;\0&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; { if(i&amp;lt;=(pos-1))&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  { cout&amp;lt;&amp;lt;str[i];i++;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  else if(substr[j]!=&amp;#39;\0&amp;#39;)&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;      {     cout&amp;lt;&amp;lt;substr[j];j++;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;  else {cout&amp;lt;&amp;lt;str[i];i++;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; }&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/239491752023238466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/insertdelete-substring-from-given.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/239491752023238466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/239491752023238466'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/insertdelete-substring-from-given.html' title='Insert,delete a substring from a given position of mainstring'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6206379159301365957.post-7584981552752820880</id><published>2011-11-06T23:17:00.001-08:00</published><updated>2011-11-06T23:17:23.770-08:00</updated><title type='text'>constructor and destructor invocation in inheritance</title><content type='html'>&lt;a href=&quot;http://codingdatastructure.blogspot.com&quot;&gt;codingdatastructure.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;div&gt;&lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;/*Program to illustrate constructor and&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; destructor invocation in inheritance*/&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;class base1&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{public:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            base1()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Constructor of base1.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            ~base1()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Destructor of base1.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;};&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;class base2&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{public:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            base2()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Constructor of base2.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            ~base2()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Destructor of base2.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;};&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;class derived: public base1,public base2&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{public:&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            derived()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Constructor of derived.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            ~derived()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;            {cout&amp;lt;&amp;lt;&amp;quot;Destructor of derived.\n&amp;quot;;}&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;};&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;void main()&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;{clrscr();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; derived d;   //d is an object of derived class&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt; getch();&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNoSpacing&quot;&gt;&lt;span style=&quot;font-size:12.0pt&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://codingdatastructure.blogspot.com/feeds/7584981552752820880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/constructor-and-destructor-invocation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7584981552752820880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6206379159301365957/posts/default/7584981552752820880'/><link rel='alternate' type='text/html' href='http://codingdatastructure.blogspot.com/2011/11/constructor-and-destructor-invocation.html' title='constructor and destructor invocation in inheritance'/><author><name>GHANSHYAM GUPTA</name><uri>http://www.blogger.com/profile/10650116670057441185</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>