Thursday, July 30, 2009

How to write pseudo code in c++ program. what the tech.?

#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int a,b,c,d,e,f,g,i,tmp,tmpf,tmpg;


double fact=1;


clrscr();


cout%26lt;%26lt;"\t\t Please Enter 7 Number Between 0-100\n\n";


cout%26lt;%26lt;"Enter The value of A = ";


cin%26gt;%26gt;a;


cout%26lt;%26lt;"Enter The value of B = ";


cin%26gt;%26gt;b;


cout%26lt;%26lt;"Enter The value of C = ";


cin%26gt;%26gt;c;


cout%26lt;%26lt;"Enter The value of D = ";


cin%26gt;%26gt;d;


cout%26lt;%26lt;"Enter The value of E = ";


cin%26gt;%26gt;e;


cout%26lt;%26lt;"Enter The value of F = ";


cin%26gt;%26gt;f;


cout%26lt;%26lt;"Enter The value of G = ";


cin%26gt;%26gt;g;


clrscr();


cout%26lt;%26lt;"\t\t\t\tThe Entered Numbers are";





cout%26lt;%26lt;"\nA="%26lt;%26lt;a%26lt;%26lt;"\nB="%26lt;%26lt;b%26lt;%26lt;"\nC="%26lt;%26lt;c%26lt;...


cout%26lt;%26lt;"The Sum Of First Two Numbers is = "%26lt;%26lt;a+b;


cout%26lt;%26lt;"\nThe Average of first three numbers is = "%26lt;%26lt;double(a+b+c)/3;


cout%26lt;%26lt;"\nThe Product of last two number is = "%26lt;%26lt;f*g;


//Logic For finding Greatest of all Numbers


if(a%26gt;b%26amp;%26amp;a%26gt;c%26amp;%26amp;a%26gt;d%26amp;%26amp;a%26gt;e%26amp;%26amp;a%26gt;f%26amp;%26amp;a%26gt;g)


cout%26lt;%26lt;"\nThe Greatest Number is = "%26lt;%26lt;a;


else if(b%26gt;a%26amp;%26amp;b%26gt;c%26amp;%26amp;b%26gt;d%26amp;%26amp;b%26gt;e%26amp;%26amp;b%26gt;f%26amp;%26amp;b%26gt;g)


cout%26lt;%26lt;"\nThe Gr

How to write pseudo code in c++ program. what the tech.?
Psuedo code is just a way of describing a program, algorithm, etc.


For instance, Pseudo code for an algorithm calculating the maxmimum of two integers could be: (Note: Psuedo code can be written any way, with the main concepts being the same)


// Algorithm for finding the maximum of two integers


input arguments: a, b


output arguments: c


compare a with b


if b is greater than a,


then make c equal b,


return c;


else


then make c equal a,


return c;





Whereas code in c++ could be something like:


int max(int a, int b) {


if (b %26gt; a) {


return b;


} else {


return a;


}


}





Note: the above is a simple implementation for beginners. For experts, it could be changed to:


int max(int a, int b) {


(b %26gt; a) ? return b : return a;


}


For all the people who say, its easier to use this or to do that.


Hope this explains psuedo code.


No comments:

Post a Comment