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

<channel>
	<title>C++ Programs | Student Projects</title>
	<atom:link href="https://studentprojects.in/category/software-development/cpp/cpp-programs/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 04:52:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Program to implement Kruskal algorithm in c++</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/program-to-implement-kruskal-algorithm-in-c/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/program-to-implement-kruskal-algorithm-in-c/#respond</comments>
		
		<dc:creator><![CDATA[surbhi]]></dc:creator>
		<pubDate>Tue, 24 May 2022 08:55:07 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=4338</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">// kruskal minimum spanning tree
#include&lt;iostream.h>

#include&lt;conio.h>

//structure for graph

struct str {
  int edge, n1, n2;
}
s0[20], s1[20];

//structure for checking nodes

struct st {
  int val, flag;
}
s2[20];

void input();
void filter();
void sort();
void min();
void update(int, int, int);

int n, e, cnt = 0, Tcost = 0;
int link[10][10];

void main() {
  clrscr();
  input();
  cout &lt;&lt; “this is filtered output\ n”;
  filter();
  cout &lt;&lt; “this is sorted output\ n”;
  sort();
  min();
  cout &lt;&lt; “\nTcost is“ &lt;&lt; Tcost;
  getch();
}

void input() {
  cout &lt;&lt; “enter no.of nodes and edges\ n”;
  cin >> n >> e;
  cout &lt;&lt; “enter input
  for upper triangle matrix\ n”;
  for (int i = 0; i &lt; n; i++) {
    for (int j = 0; j &lt; n; j++) {
      if (i != j &amp;&amp; j > i) {
        cout &lt;&lt; “enter link of node“ &lt;&lt; i &lt;&lt; ”to node“ &lt;&lt; j &lt;&lt; endl;
        cin >> link[i][j];
      } else {
        if (i == j)
          link[i][j] = 0;
        else
          link[i][j] = link[j][i];
      }
    }
  }
}

int k = 0, count = 0;

void filter() {
  for (int i = 0; i &lt; n; i++) {
    for (int j = 0; j &lt; n; j++) {
      if (link[i][j] != 0) {
        s0[k].edge = link[i][j];
        s0[k].n1 = i;
        s0[k].n2 = j;
        k++;
        count++;
      }
    }
  }
  i = 0;
  int j = 0;
  int flag = 1;
  for (int l = 0; l &lt; count; l++) {
    if (i == 0) {
      s1[j].edge = s0[i].edge;
      s1[j].n1 = s0[i].n1;
      s1[j].n2 = s0[i].n2;
      i++;
      j++;
    } else {
      k = 0;
      while (k &lt; j) {
        if (s1[k].edge == s0[i].edge &amp;&amp; s1[k].n1 == s0[i].n2 &amp;&amp; s1[k].n2 == s0[i].n1) {
          flag = 0;
          break;
        } else
          k++;
      }
      if (flag) {
        s1[j].edge = s0[i].edge;
        s1[j].n1 = s0[i].n1;
        s1[j].n2 = s0[i].n2;
        i++;
        j++;
        cnt++;
      } else {
        i++;
        flag = 1;
      }
    }
  }
  for (i = 0; i &lt;= cnt; i++)
    cout &lt;&lt; s1[i].edge &lt;&lt; “\t” &lt;&lt; s1[i].n1 &lt;&lt; “\t” &lt;&lt; s1[i].n2 &lt;&lt; endl;
}

void sort() {
  for (int i = 0; i &lt;= cnt - 1; i++) {
    for (int j = 0; j &lt;= cnt - i - 1; j++) {
      if (s1[j].edge > s1[j + 1].edge) {
        int t = s1[j].edge;
        s1[j].edge = s1[j + 1].edge;
        s1[j + 1].edge = t;

        int t1 = s1[j].n1;
        s1[j].n1 = s1[j + 1].n1;
        s1[j + 1].n1 = t1;

        int t2 = s1[j].n2;
        s1[j].n2 = s1[j + 1].n2;
        s1[j + 1].n2 = t2;
      }
    }
  }
  for (i = 0; i &lt; cnt; i++)
    cout &lt;&lt; s1[i].edge &lt;&lt; “\t” &lt;&lt; s1[i].n1 &lt;&lt; “\t” &lt;&lt; s1[i].n2 &lt;&lt; endl;

}

void min() {

  //initialize s2 structure

  for (int i = 0; i &lt; n; i++) {
    s2[i].val = i;
    s2[i].flag = i + 1;
  }

  int u, v, y, z;
  int cur = n;

  for (i = 0; i &lt; e; i++) {
    y = s1[i].n1;
    z = s1[i].n2;
    //cout&lt;&lt;“y &amp; z “&lt;&lt;y&lt;&lt;z;
    u = s2[y].flag;
    v = s2[z].flag;
    if (u != v) {
      Tcost += s1[i].edge;
      cout &lt;&lt; “\nedge“ &lt;&lt; y &lt;&lt; “– > ” &lt;&lt; z;
    }
    cur = cur + 1;
    update(y, z, cur);
  }
}

void update(int y, int z, int cur) {
  for (int i = 0; i &lt; n; i++) {
    if (i != y) {
      if (s2[y].flag == s2[i].flag)
        s2[i].flag = cur;
    }

    if (i != z) {
      if (s2[z].flag == s2[i].flag)
        s2[i].flag = cur;
    }
  }
  s2[y].flag = cur;
  s2[z].flag = cur;
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/program-to-implement-kruskal-algorithm-in-c/">Program to implement Kruskal algorithm in c++</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/program-to-implement-kruskal-algorithm-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to count set bits in a number</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-count-set-bits-in-a-number/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-count-set-bits-in-a-number/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 14:10:24 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9042</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">First version:

  int CoutSetBits(int Num) {

  for (int count = 0; Num; Num >>= 1) {
    if (Num &amp; 1)
      count++;
  }
  return count;
}

Optimized version:

  int CoutSetBits(int Num) {

  for (int count = 0; Num; count++) {
    Num &amp;= Num - 1;
  }
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-count-set-bits-in-a-number/">How to count set bits in a number</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-count-set-bits-in-a-number/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to return Nth the node from the end of the linked list in one pass</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-return-nth-the-node-from-the-end-of-the-linked-list-in-one-pass/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-return-nth-the-node-from-the-end-of-the-linked-list-in-one-pass/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 14:07:44 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9040</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">Node * GetNthNode(Node * Head, int NthNode) {
  Node * pNthNode = NULL;
  Node * pTempNode = NULL;
  int nCurrentElement = 0;

  for (pTempNode = Head; pTempNode != NULL; pTempNode = pTempNode -> pNext) {
    nCurrentElement++;
    if (nCurrentElement - NthNode == 0) {
      pNthNode = Head;
    } else
    if (nCurrentElement - NthNode > 0) {
      pNthNode = pNthNode -> pNext;
    }
  }
  if (pNthNode) {
    return pNthNode;
  } else
    return NULL;
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-return-nth-the-node-from-the-end-of-the-linked-list-in-one-pass/">How to return Nth the node from the end of the linked list in one pass</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-return-nth-the-node-from-the-end-of-the-linked-list-in-one-pass/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to write a function that finds the last instance of a character in a string</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-finds-the-last-instance-of-a-character-in-a-string/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-finds-the-last-instance-of-a-character-in-a-string/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 14:06:02 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9038</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">char * lastchar(char * String, char ch) {
  char * pStr = NULL;

  // traverse the entire string

  while ( * String++ != NULL) {
    if ( * String == ch)
      pStr = String;
  }

  return pStr;
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-finds-the-last-instance-of-a-character-in-a-string/">How to write a function that finds the last instance of a character in a string</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-finds-the-last-instance-of-a-character-in-a-string/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to generate a Fib numbers</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-generate-a-fib-numbers/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-generate-a-fib-numbers/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 14:04:49 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9036</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">int fib( n ) // recursive version
{
	
	if ( n &lt; 2 )
		return 1;
	else
		return fib ( n –1 ) + fib ( n –2 );

}

int fib( n ) //iterative version
{
	int f1 =1, f2 = 1;

	if ( n &lt; 2 )
		return 1;	
	for ( i = 1; i &lt; N; i++)
	{
		f = f1 + f2;
		f1= f2;
		f = f1;
	}

	return f;
}
</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-generate-a-fib-numbers/">How to generate a Fib numbers</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-generate-a-fib-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to find the factorial of a number</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-find-the-factorial-of-a-number/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-find-the-factorial-of-a-number/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 14:03:50 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9034</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">//
// recursive version
//

int Factorial(int Num) {

  If(num > 0)
  return Num * Factorial(Num– 1);
  else
    return 1;
}

//
// iterative version
//

int Factorial(int Num) {
  int I
  int result = 1;

  for (I = Num; I > 0; I--) {
    result = result * I;
  }

  return result;
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-find-the-factorial-of-a-number/">How to find the factorial of a number</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-find-the-factorial-of-a-number/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to print an integer using only putchar</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-print-an-integer-using-only-putchar/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-print-an-integer-using-only-putchar/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 13:48:51 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9032</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">//
//	recursive version
//
void PrintNum(int Num) {
  if (Num == 0)
    return;
  PrintNum(Num / 10);
  Puthcar(‘0’ + Num % 10);
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-print-an-integer-using-only-putchar/">How to print an integer using only putchar</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-print-an-integer-using-only-putchar/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to print a data from a binary tree in-order(ascending)</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-print-a-data-from-a-binary-tree-in-orderascending/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-print-a-data-from-a-binary-tree-in-orderascending/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 13:47:37 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9030</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">//
// recursive version
//

Void PrintTree(struct * node node) {
  if (node == NULL)
    return;

  PrintTree(node -> left);
  Printf(“ % d”, node -> data);
  PrintTree(node -> right);
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-print-a-data-from-a-binary-tree-in-orderascending/">How to print a data from a binary tree in-order(ascending)</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/how-to-print-a-data-from-a-binary-tree-in-orderascending/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-takes-in-a-string-parameter-and-checks-to-see-whether-or-not-it-is-an-integer-and-if-it-is-then-return-the-integer-value/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-takes-in-a-string-parameter-and-checks-to-see-whether-or-not-it-is-an-integer-and-if-it-is-then-return-the-integer-value/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 13:45:49 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9028</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;stdio.h>

int strtoint(char * s) {
  int index = 0, flag = 0;

  while ( * (s + index) != '\0') {
    if (( * (s + index) >= '0') &amp;&amp;
      *
      (s + index) &lt;= '9') {
      flag = 1;
      index++;
    } else {
      flag = 0;
      break;
    }
  }

  if (flag == 1)
    return atoi(s);
  else
    return 0;
}

main() {
  printf("%d", strtoint("0123"));
  printf("\n%d", strtoint("0123ii"));
}</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-takes-in-a-string-parameter-and-checks-to-see-whether-or-not-it-is-an-integer-and-if-it-is-then-return-the-integer-value/">How to write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/how-to-write-a-function-that-takes-in-a-string-parameter-and-checks-to-see-whether-or-not-it-is-an-integer-and-if-it-is-then-return-the-integer-value/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to multiply a number by 7 without using * and + operator</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/how-to-multiply-a-number-by-7-without-using-and-operator/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/how-to-multiply-a-number-by-7-without-using-and-operator/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 12 Apr 2022 13:41:06 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9024</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code lang="cpp" class="language-cpp">NewNum = Num &lt;&lt; 3; // multiplied by 2 ^ 3 = 8

	NewNum = NewNum - Num; // 8 – 1 = 7</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/how-to-multiply-a-number-by-7-without-using-and-operator/">How to multiply a number by 7 without using * and + operator</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/how-to-multiply-a-number-by-7-without-using-and-operator/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
