tag:blogger.com,1999:blog-25379958981352972082024-03-12T20:22:56.345-07:00HelpcodesThis blog is a collection of some C++ source codes.Unknownnoreply@blogger.comBlogger16125tag:blogger.com,1999:blog-2537995898135297208.post-34102876037559813842011-06-25T15:04:00.000-07:002011-11-28T01:16:39.618-08:00C++ Program that Converts Arabic Numerals to Roman Numerals<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Arabic to Roman Numerals Converter</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Roman Numeral Examples: I,V,X,C,D,M</span><span style="font-size: small;"> </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Arabic Numeral Examples: 0,1,2,3,4,5,6,7,8,9</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description: This program converts Arabic Numerals into Roman Numerals. </span><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span class="fullpost"> <span style="font-size: small;">As you can see in the screenshot below, you can enter any Arabic number you want. I entered number 99,999,3456, then, it displayed their corresponding Roman Numeral Format.</span></span><br />
<span class="fullpost"><span style="font-size: small;"> </span><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif; text-align: left;"><span class="fullpost"><span style="font-size: small;"></span><span style="font-size: small;"></span></span><br />
<div class="separator" style="clear: both; text-align: center;"><span class="fullpost"><span style="font-size: small;"><a href="http://3.bp.blogspot.com/-nbdf_wQLqfQ/TfhYepH-tPI/AAAAAAAAAC0/otdsLEZukPs/s1600/converter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="http://3.bp.blogspot.com/-nbdf_wQLqfQ/TfhYepH-tPI/AAAAAAAAAC0/otdsLEZukPs/s400/converter.png" width="400" /></a></span></span></div><span class="fullpost"><span style="font-size: small;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
</span></span><br />
<div class="scrollbox" style="text-align: left;"><span class="fullpost"><span style="font-size: small;"><span style="font-size: small;">//Below are the Codes of the Program:</span></span></span><br />
<span class="fullpost"><span style="font-size: small;">#include <iostream.h></span></span><br />
<span class="fullpost"><span style="font-size: small;">#include <string.h></span></span><br />
<span class="fullpost"><span style="font-size: small;">#include <math.h></span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;">int main()</span></span><br />
<span class="fullpost"><span style="font-size: small;">{</span></span><br />
<span class="fullpost"><span style="font-size: small;"> char ans, ch;</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< " [1] Conversion of Arabic Number to Roman Number Format\n";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> do</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< " Let's test your keyboard. Type this number [1]: ";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cin>> ch;</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> if(ch=='1')</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {</span></span><br />
<span class="fullpost"><span style="font-size: small;"> int yr, m, cm, d, c, xc, l, x, ix, v, i;</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< " Enter any ARABIC NUMBER you want: ";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cin>> yr;</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<<"\n In Roman Numeral Format: ";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(m = 1000;yr >= m; yr -= 1000)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"M";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(cm = 900; yr >= cm; yr -= 900)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<< "CM";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(d = 500;yr >= d; yr -= 500)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"D";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> if(yr >= 400){ cout<<"CD"; yr -= 400; }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> else {</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(c = 100;yr >= c; yr -= 100)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"C";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(xc = 90; yr >= xc; yr -= 90)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<< "XC";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(l = 50;yr >= l; yr -= 50)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"L";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> if(yr >= 40){ cout<<"XL"; yr -= 40; }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> else {</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(x = 10;yr >= x; yr -= 10)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"X";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(ix = 9; yr >= ix; yr -= 9)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<< "IX";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(v = 5;yr >= v; yr -= 5)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"V";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> if(yr >= 4){ cout<<"IV"; yr -= 4; }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> else {</span></span><br />
<span class="fullpost"><span style="font-size: small;"> for(i = 1;yr >= i; yr -= 1)</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {cout<<"I";}</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }</span></span><br />
<span class="fullpost"><span style="font-size: small;"> else</span></span><br />
<span class="fullpost"><span style="font-size: small;"> {</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< " Invalid input number!\n";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< endl;</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< "\n\n Try Again?[y/n]: ";</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cin>> ans;</span></span><br />
<span class="fullpost"><span style="font-size: small;"> }while(ans=='y'||ans=='Y');</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cout<< " Thank You!\n";</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cin.get();</span></span><br />
<span class="fullpost"><span style="font-size: small;"> cin.get();</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;"> return 0;</span></span><br />
<span class="fullpost"><span style="font-size: small;"><br />
</span></span><br />
<span class="fullpost"><span style="font-size: small;">}</span></span></div></div><div style="font-family: Georgia,"Times New Roman",serif;"></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-7872238528477957362011-06-25T14:59:00.000-07:002011-11-28T01:16:41.416-08:00C++ Program of The Cramer's Rule<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Cramer's Rule</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Cramer's rule is a theorem, which gives an expression for the solution of a system of linear equations with as many equations as unknowns, valid in those cases where there is a unique solution. The solution is expressed in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations.</span><span style="font-size: small;"> </span><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description of the Program: This program computes the determinant and shows the result of the 3 unknown variables using Cramer's Rule.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span class="fullpost"> <br />
<span style="font-size: small;">As you can see in the screenshot below, I entered just the example equations. First equation is (3X)^3+(4X)^2+5X=6, second is (2X)^3+(7X)^2+5X=3, and the last equation (X)^3+(3X)^2+4X=2</span><br />
</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span class="fullpost"><a href="http://4.bp.blogspot.com/-iNLF0JTpdIg/TgJrW6DEcRI/AAAAAAAAADc/3SHJnQFd8L8/s1600/cramers.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="353" src="http://4.bp.blogspot.com/-iNLF0JTpdIg/TgJrW6DEcRI/AAAAAAAAADc/3SHJnQFd8L8/s400/cramers.jpg" width="400" /></a></span></div><span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">After entering all the coefficients of the equation in the screenshot above, it displayed the determinant of the three equations which is 22. Then, the individual determinants, 45,-7, and 5 after substituting the number on the right side of the equality in their corresponding column. </span><span style="font-size: small;">Lastly, it displayed the result of the three unknown variables,X1,X2,and X3. </span><br />
<input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
<br />
<span style="font-size: small;">//Below are Codes of the Program:</span><br />
</span><br />
<div class="scrollbox"><span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">#include<iostream.h></span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">void input(int array[][3], int array1[][1]);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int determinent(int array[][3]);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int calculate(int array[][3], int a, int b, int c);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int copy(int array[][3], int array1[][1], int a);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">void comp_copy(int array[][3], int array1[][3]);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int main()</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"Enter a 3 by 3 matrix from a given system. First, enter the 1st row, then,\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"\nthe first entry on the right side of the equality. \n\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"Provide a space for each number. \n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"\nLike this:\n\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<" 3 4 5 6 -> 6 is the number on the right side of the equality\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<" 2 7 5 3 \n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<" 1 3 4 2 \n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> bool sahi=true;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(sahi)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"Enter now...\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int matrix[3][3];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int matrix1[3][1];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int reserve[3][3];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int det00, detr[3], sp1=0,cont=0, teen=1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> char in;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> input(matrix, matrix1);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> comp_copy(reserve, matrix);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> det00=determinent(matrix);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(sp1<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> detr[cont]=copy(matrix, matrix1, sp1);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> comp_copy(matrix,reserve);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cont++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> sp1++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cont=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(cont<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"x"<<teen<<" = "<< detr[cont]<<" /"<<det00<<endl;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cont++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> teen++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"If you want to exit press n else press any key\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cin>>in;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> if(in=='n' || in=='N')</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> return 1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> return 0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">void input(int array[][3], int array1[][1])</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int rows=0, col=0, x=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(rows<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(col<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cin>>array[rows][col];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cin>>array1[x][0];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> x++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> rows++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int determinent(int array[][3])</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int rows=1, col=1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int z=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int temp=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int cont=1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int x=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(x<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> temp=temp+cont*(array[0][x]*calculate(array,rows, col, z));</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col=col*0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> z=z+cont;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cont=cont*-1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> x++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<"\nDeterminant of the matrix above is "<<temp<<"\n\n";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> return temp;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int calculate(int array[][3], int a, int b, int c)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int temp1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> temp1=(array[a][b]*array[a+1][b+1+c])-(array[a+1][b]*array[a][b+1+c]);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> return temp1;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">int copy(int array[][3], int array1[][1], int a)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int col=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int temp;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(col<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> array[col][a]=array1[col][0];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int i=0, j=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(i<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> j=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(j<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<array[i][j]<<" ";</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> j++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> cout<<endl;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> i++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> temp=determinent(array);</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> return temp;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">void comp_copy(int array[][3], int array1[][3])</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">{</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> int rows=0, col=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(rows<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col=0;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> while(col<3)</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> {</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> array[rows][col]=array1[rows][col];</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> col++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> rows++;</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"> }</span><br />
<span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;">}</span></div><br />
<div style="font-family: Georgia,"Times New Roman",serif;"></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-54427909409249559612011-06-25T14:58:00.000-07:002011-10-07T03:21:40.849-07:00C++ Program of the Different Types of Triangles<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Different Triangles</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">A triangle is one of the basic shapes of geometry: a polygon with three corners or vertices and three sides or edges which are line segments. A triangle with vertices <i>A</i>, <i>B</i>, and <i>C</i> is denoted </span><span style="font-size: small; white-space: nowrap;"><img alt="\triangle" class="tex" src="http://upload.wikimedia.org/math/f/5/d/f5d889f32d6794e1bc2ed394e9688c76.png" /> <i>ABC</i></span><span style="font-size: small;">.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"> Description of the Program: This program displays the different types of triangle by entering their heights.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span><span class="fullpost"> <br />
<span style="font-size: small;">As you can see in the screenshot below, you are given the choice which type of triangle would you like to display. I entered letter<i> a </i>and the height of the triangle which is 6 in any units,then, it displayed the right triangle figure.<i> </i></span><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif; text-align: center;"><span class="fullpost"><span style="font-size: small;"></span></span><br />
<div class="separator" style="clear: both; text-align: center;"><span class="fullpost"><span style="font-size: small;"><a href="http://1.bp.blogspot.com/-lvTQCaPgguM/TgW24HURUmI/AAAAAAAAAGU/Y6-d0VqyJto/s1600/triangle.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="315" src="http://1.bp.blogspot.com/-lvTQCaPgguM/TgW24HURUmI/AAAAAAAAAGU/Y6-d0VqyJto/s400/triangle.jpg" width="400" /></a></span></span></div></div><span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
<span style="font-size: small;">//Below are the Codes of the Program:</span><br />
<div style="text-align: left;"><br />
</div><div class="scrollbox">#include<stdio.h><br />
#include<conio.h><br />
#include<iostream.h><br />
int z=1;<br />
void right_tri( int a);<br />
void up_right_tri( int a);<br />
void up_left_tri( int a);<br />
void left_tri( int a);<br />
void inverse_vertical_tri( int a);<br />
void vertical_tria(int a);<br />
void vertical_diamond( int a);<br />
void horizontal_diamond( int a);<br />
void oposite_vertical( int a);<br />
void oposite_horizontal( int a);<br />
void input( int&a);<br />
void input1( char&a);<br />
void main()<br />
{<br />
int a,b,r;<br />
char s;<br />
input1(s);<br />
input(a);<br />
r=a;<br />
if(s=='a')<br />
right_tri(a);<br />
else if(s=='b')<br />
left_tri(a);<br />
else if(s=='c')<br />
up_right_tri(a);<br />
else if(s=='d')<br />
up_left_tri(a);<br />
else if(s=='e')<br />
inverse_vertical_tri(a);<br />
else if(s=='f')<br />
vertical_tria(a);<br />
else if(s=='g')<br />
vertical_diamond(r);<br />
else if(s=='h')<br />
horizontal_diamond(r);<br />
else if(s=='i')<br />
oposite_vertical(r);<br />
else if(s=='j')<br />
oposite_horizontal(r);<br />
getch();<br />
}<br />
<br />
<br />
void input1( char&a)<br />
{<br />
cout<<"\nChoose what type of triangle would you like to display: ";<br />
cout<<"\n\ta. A Right Triangle";<br />
cout<<"\n\tb. A Left Triangle";<br />
cout<<"\n\tc. An Up Right Triangle";<br />
cout<<"\n\td. An Up Left Triangle";<br />
cout<<"\n\te. A Reverse Vertical Triangle";<br />
cout<<"\n\tf. A Vertical Triangle";<br />
cout<<"\n\tg. A Vertical Diamond";<br />
cout<<"\n\th. A Horizontal Diamond";<br />
cout<<"\n\ti. An Opposite Vertical Triangle";<br />
cout<<"\n\tj. An Opposite Horizontal Triangle\n";<br />
a=getch();<br />
cout<<" You have enter the letter of your choice.\n";<br />
}<br />
<br />
void input( int&a)<br />
{<br />
cout<<"Enter the height of the triangle:\n";<br />
cin>>a;<br />
}<br />
<br />
void oposite_horizontal( int a)<br />
{<br />
cout<<"\n\Opposite Horizontal Triangle\n\n";<br />
if(a%2==0)<br />
{<br />
for(int b=0;b<=(a/2)+1;b++)<br />
{<br />
for(int c=b;c>0;c--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int y=b;y<=a/2;y++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int e=b;e<=a/2;e++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int zaa=b;zaa>0;zaa--)<br />
{<br />
cout<<"*";<br />
}<br />
<br />
cout<<"\n";<br />
}<br />
<br />
for(int x=1;x<=a/2;x++)<br />
{<br />
for(int y=x;y<=a/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int as=x;as>=1;as--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int y=x;y<=a/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
else<br />
{<br />
for(int b=0;b<=(a/2)+1;b++)<br />
{<br />
for(int c=b;c>0;c--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int y=b;y<=a/2;y++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int e=b;e<=a/2;e++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int zaa=b;zaa>0;zaa--)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
for(int x=1;x<=a/2;x++)<br />
{<br />
for(int y=x;y<=a/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int as=x;as>=1;as--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int y=x;y<=a/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
}<br />
<br />
<br />
void oposite_vertical( int a)<br />
{<br />
cout<<"\n\Opposite Vertical Triangle\n\n";<br />
if(a%2==0)<br />
{<br />
for(int b=0;b<(a+1)/2;b++)<br />
{<br />
for(int c=b;c>0;c--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int y=b;y<(a+1)/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
for(int e=b;e<(a-1)/2;e++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
<br />
<br />
for(int x=1;x<=(a+1)/2;x++)<br />
{<br />
for(int y=x;y<(a+1)/2;y++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int as=x;as>1;as--)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
else<br />
{<br />
for(int b=1;b<(a+1)/2;b++)<br />
{<br />
for(int c=b-1;c>0;c--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int y=b;y<=(a+1)/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
for(int e=b;e<=(a-1)/2;e++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
for(int x=1;x<=(a+1)/2;x++)<br />
{<br />
for(int y=x;y<(a+1)/2;y++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int as=x;as>1;as--)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
}<br />
<br />
void horizontal_diamond( int a)<br />
{<br />
cout<<"\n\Horizontal Diamond\n\n";<br />
for(int x=1;x<=(a+1)/2;x++)<br />
{<br />
for(int y=x;y<(a+1)/2;y++)<br />
{<br />
cout<<"\t";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<"\t*";<br />
}<br />
for(int as=x;as>1;as--)<br />
{<br />
cout<<"\t*";<br />
}<br />
cout<<"\n";<br />
}<br />
for(int b=1;b<(a+1)/2;b++)<br />
{<br />
for(int c=b;c>0;c--)<br />
{<br />
cout<<"\t";<br />
}<br />
for(int y=b;y<(a+1)/2;y++)<br />
{<br />
cout<<"\t*";<br />
}<br />
for(int e=b;e<(a-1)/2;e++)<br />
{<br />
cout<<"\t*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void vertical_diamond( int a)<br />
{<br />
cout<<"\n\nVertical Diamond\n\n";<br />
for(int x=1;x<=(a+1)/2;x++)<br />
{<br />
for(int y=x;y<(a+1)/2;y++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int za=x;za>0;za--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int as=x;as>1;as--)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
for(int b=1;b<(a+1)/2;b++)<br />
{<br />
for(int c=b;c>0;c--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int y=b;y<(a+1)/2;y++)<br />
{<br />
cout<<"*";<br />
}<br />
for(int e=b;e<(a-1)/2;e++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void vertical_tria(int a)<br />
{<br />
int y=1;<br />
cout<<"\n\nVertical Triangle\n\n";<br />
for(int i=1;i<=a;i++)<br />
{<br />
for(int s=a;s>=i;s--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int a=0;a<y;a++)<br />
{<br />
cout<<"*";<br />
}<br />
y+=2;<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void inverse_vertical_tri(int a)<br />
{<br />
cout<<"\n\nInverse Vertical Triangle\n\n";<br />
int x,y,z,g,b,c,d,e;<br />
for(b=1;b<=a;b++)<br />
{<br />
for(c=b;c>0;c--)<br />
{<br />
cout<<" ";}<br />
for(g=b;g<=a;g++)<br />
{<br />
cout<<"*";<br />
}<br />
for(e=b;e<=a-1;e++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void up_left_tri( int a)<br />
{<br />
cout<<"\n\nUp Right Triangle Facing Left\n\n";<br />
for(int xa=1;xa<=a;xa++)<br />
{<br />
for(int x=1;x<z;x++)<br />
{<br />
cout<<" ";<br />
}<br />
for(int xz=xa;xz<=a;xz++)<br />
{<br />
cout<<"*";<br />
}<br />
z++;<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void up_right_tri( int a)<br />
{<br />
cout<<"\n\nUp Right Triangle Facing Right\n\n";<br />
for(int xa=1;xa<=a;xa++)<br />
{<br />
for(int x=a;x>=xa;x--)<br />
{<br />
cout<<"*";<br />
}<br />
for(int xz=0;xz<=z;xz++)<br />
{<br />
cout<<" ";<br />
}<br />
z++;<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void left_tri( int a)<br />
{<br />
cout<<"\n\nLeft Triangle\n\n";<br />
for(int xa=1;xa<=a;xa++)<br />
{<br />
for(int x=a;x>xa;x--)<br />
{<br />
cout<<" ";<br />
}<br />
for(int xz=0;xz<z;xz++)<br />
{<br />
cout<<"*";<br />
}<br />
z++;<br />
cout<<"\n";<br />
}<br />
}<br />
<br />
void right_tri( int a)<br />
{<br />
cout<<"\n\nRight Triangle\n\n";<br />
for(int xa=0;xa<=a;xa++)<br />
{<br />
for(int x=0;x<xa;x++)<br />
{<br />
cout<<"*";<br />
}<br />
cout<<"\n";<br />
}<br />
}</div></span><div style="font-family: Georgia,"Times New Roman",serif;"></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-80513274984616203832011-06-25T14:56:00.000-07:002011-10-07T03:21:51.583-07:00C++ Program That Counts The Number Of Letters In A Word<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Number of Letters in a Word</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description of the Program: This program tally how many a letter has in a given word.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span> <span class="fullpost"> <br />
<span style="font-size: small;">As you can see in the screenshot below, I entered the word Bourgeoisie,then, it tallied how many letter B,e,g,i,o,r,s, and u in this word. Just make it sure, you put a dot or period sign after you enter any word. </span><br />
</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span class="fullpost"><a href="http://2.bp.blogspot.com/-O9m88kfecWc/TgM3mty-ewI/AAAAAAAAAEY/IazgGVlZQ0A/s1600/words.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="270" src="http://2.bp.blogspot.com/-O9m88kfecWc/TgM3mty-ewI/AAAAAAAAAEY/IazgGVlZQ0A/s400/words.jpg" width="400" /></a></span></div><span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span><br />
<input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
<span style="font-size: small;">//Below are the Codes of the Program:</span><br />
<div class="scrollbox">#include<iostream.h><br />
#include<conio.h><br />
void swap (char& a, char& b)<br />
{<br />
char c,d;<br />
c=a;<br />
d=b;<br />
a=d;<br />
b=c;<br />
}<br />
<br />
<br />
int main()<br />
{ char name[20];<br />
int t[20]={0},c=0,count=0,con[10]={0},z=0;<br />
cout<<"When you enter any word be sure it has a '.' at the end.\n";<br />
cout<<"Example: Mississippi. \n";<br />
cout<<"\n\Enter any word: ";<br />
<br />
cin>>name;<br />
<br />
for(int d=0;d<20;d++)<br />
{<br />
if(name[d]=='.')<br />
d=20;<br />
<br />
else count++;<br />
<br />
}<br />
<br />
<br />
for(int g=0;g<count;g++)<br />
{<br />
for(int e=0;e<count;e++)<br />
{<br />
if((e+1)<count)<br />
{<br />
if (name[e]>name[e+1])<br />
swap(name[e],name[e+1]);<br />
}<br />
}<br />
}<br />
<br />
<br />
for(int f=0;f<count;f++)<br />
if(name[f]!=name[f+1])<br />
{<br />
<br />
cout<< name[f];<br />
for(int fa=0;fa<count;fa++)<br />
{<br />
if(name[f]==name[fa])<br />
con[z]++;<br />
<br />
}<br />
<br />
cout<<"\t"<< con[z]<<"\n";<br />
z++;<br />
}<br />
<br />
getch();<br />
}</div></span><div style="font-family: Georgia,"Times New Roman",serif;"></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-39791368696171931422011-06-25T14:55:00.000-07:002011-10-07T03:20:50.400-07:00C++ Program of Number Sequence<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Number Sequence<br />
Description of the Program: This program displays the input numbers in descending order.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span><span class="fullpost"> <br />
<span style="font-size: small;">As you can see in the screenshot below, I entered 5 numbers. The numbers are 98,34,56,9 and 5. Then, it displayed the five numbers, 98-56-34-9-5 in descending order. </span><br />
</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span class="fullpost"><a href="http://1.bp.blogspot.com/-DJKhg4wFa8g/TgWs_8uCA4I/AAAAAAAAAGE/Qa2mETOWohg/s1600/sequence.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="344" src="http://1.bp.blogspot.com/-DJKhg4wFa8g/TgWs_8uCA4I/AAAAAAAAAGE/Qa2mETOWohg/s400/sequence.jpg" width="390" /></a></span></div><span class="fullpost" style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
<span style="font-size: small;">//Below are the Codes of the Program:</span><br />
<div class="scrollbox">#include<iostream.h><br />
#include<conio.h><br />
void swap (int& a, int& b)<br />
{<br />
int c,d;<br />
c=a;<br />
d=b;<br />
a=d;<br />
b=c;<br />
}<br />
<br />
<br />
int main()<br />
{<br />
int c,a[90]={0},b[90]={0},d,i;<br />
cout<<"How many numbers? ";<br />
cin>>c;<br />
for(int d=0;d<c;d++)<br />
{<br />
cout<<"\n";<br />
cout<<(d+1)<<" input: ";<br />
cin>>a[d];<br />
}<br />
<br />
for(int g=0;g<c;g++)<br />
{<br />
for(int e=0;e<c;e++)<br />
{<br />
if((e+1)<c)<br />
{<br />
if (a[e]<a[e+1])<br />
swap(a[e],a[e+1]);<br />
}<br />
}<br />
}<br />
<br />
for(int f=0;f<c;f++)<br />
{<br />
<br />
cout<<a[f]<<"\t";<br />
}<br />
getch();<br />
}</div></span><div style="font-family: Georgia,"Times New Roman",serif;"></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-46272238954548554122011-06-25T14:54:00.000-07:002011-10-07T03:20:12.759-07:00C++ Program That Converts Roman Numerals to Arabic Numerals<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Roman Numerals to Arabic Numerals Converter <br />
Description of the Program: This program converts Roman Numerals into Arabic Numerals.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As you can see in the screenshot below, I entered the Roman Numeral CMLXLIX which has seven letters. Then, the Arabic Numeral Format 999 displayed. You can only enter 9 letters for any Roman Numeral Format... <br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;"></span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="http://1.bp.blogspot.com/-M9M5sth52w0/TgWxGu2vPMI/AAAAAAAAAGM/azf6zCEMhGc/s1600/roman%2Bto%2Barabic.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="281" src="http://1.bp.blogspot.com/-M9M5sth52w0/TgWxGu2vPMI/AAAAAAAAAGM/azf6zCEMhGc/s400/roman%2Bto%2Barabic.jpg" width="400" /></a></span></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include <iostream.h><br />
#include <string.h><br />
#include <conio.h><br />
#include <math.h><br />
int main()<br />
{ int t=0,x[10]={0},f=0;<br />
char a[10], b[10];<br />
cout<<"You must type big letters. Just keep on pressing ENTER \n";<br />
cout<<"until you get the Arabic Numeral Format.\n";<br />
cout<<"Example of Roman Numerals: \n";<br />
cout<<" CMLXLIX \n";<br />
cout<<" DCLXIX \n";<br />
cout<<" CXLIII \n";<br />
cout<<" MDLV \n";<br />
cout<<"Enter any Roman Numerals: ";<br />
for(int i=0; i<10; i++)<br />
{<br />
cin.get(a[i]);<br />
if(a[i]==' ')i=10;<br />
t++;<br />
}<br />
t=t-1;<br />
<br />
for(int i=0; i<t; i++)<br />
{<br />
if(a[i]=='M')<br />
{x[i]=1000;}<br />
else if(a[i]=='D')<br />
{x[i]=500;}<br />
else if(a[i]=='C')<br />
{x[i]=100;}<br />
else if(a[i]=='L')<br />
{x[i]=50;}<br />
else if(a[i]=='X')<br />
{x[i]=10;}<br />
else if(a[i]=='V')<br />
{x[i]=5;}<br />
else if(a[i]=='I')<br />
{x[i]=1;}<br />
else if(a[i]==' ')<br />
{x[i]=0;}<br />
}<br />
for(int i=0; i<t; i++)<br />
{<br />
if(abs(x[i])<abs(x[i+1])&&(i+1)<t)<br />
{<br />
x[i]=x[i]*(-1);<br />
x[i+1]=x[i+1];<br />
}<br />
}<br />
for(int i=0; i<t; i++)<br />
{<br />
f=f+x[i];<br />
}<br />
cout<< "\nArabic Numeral Format: " << f << endl;<br />
<br />
getch();<br />
return 0;<br />
}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-51754091041772312882011-06-25T14:52:00.000-07:002011-10-07T03:19:40.335-07:00C++ Program That Displays The Calendar<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Calendar</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description of the Program: This program displays todays date and time and the calendar from the year 2000 up to the year you want.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As you can see in the screenshot below, before you will enter the year, the program will display the current date and time. Then, I entered the year 2020 and the month 2 which corresponds to the month of February. Then, it displayed the full calendar of the year 2020 from Sunday to Saturday with their corresponding dates.</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://4.bp.blogspot.com/-nIPKdlfEZAM/TgRWi3aOB9I/AAAAAAAAAEg/77nbiM0wAV0/s1600/calendar.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="http://4.bp.blogspot.com/-nIPKdlfEZAM/TgRWi3aOB9I/AAAAAAAAAEg/77nbiM0wAV0/s400/calendar.jpg" width="400" /> </a></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include<dos.h><br />
#include<iostream.h><br />
#include<conio.h><br />
#include<process.h><br />
#include<time.h><br />
/* This Class is used for generating calendar */<br />
class calen<br />
{<br />
int days; /* Will have no. of days a month has */<br />
int mm; /* Month Iterator variable [1-12] */<br />
int k; /* Days Iterator [ 0 till the days in month ] */<br />
int z; /* Iterator Variable */<br />
int p; /* Start day of every month e.g. 5 for friday */<br />
int yy; /* User Entered year */<br />
int r; /* Year Iterator variable */<br />
int calen[5][7]; /* The Matrix stores all required dates */<br />
int i,j; /* Iterator Variables */<br />
int mon; /* User entered month */<br />
public:<br />
void calen_call(void);<br />
void display(void);<br />
};<br />
<br />
void main()<br />
{<br />
clrscr();<br />
calen c;<br />
c.calen_call();<br />
c.display();<br />
getch();<br />
}<br />
<br />
void calen::calen_call(void)<br />
{<br />
<br />
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};<br />
<br />
time_t t;<br />
time(&t);<br />
cout<<"\n\n\n\t\t\tCALENDAR FROM YEAR 2000...\n\n\n";<br />
cout<<"\n\nTODAY'S DATE AND TIME: "<<ctime(&t);<br />
repeat:<br />
<br />
cout<<"\n\nENTER YEAR [2000 ...] : ";<br />
cin>>yy;<br />
<br />
if(yy<=1999)<br />
{<br />
cout<<"\n\nWRONG ENTRY";<br />
<br />
goto repeat;<br />
}<br />
<br />
if(yy%4==0)<br />
{<br />
if(yy%100==0)<br />
{<br />
if(yy%400==0)<br />
month[1]=29;<br />
else<br />
month[1]=28;<br />
}<br />
else<br />
month[1]=29;<br />
}<br />
<br />
again:<br />
cout<<"\nENTER MONTH [1-12] :";<br />
cin>>mon;<br />
<br />
if(mon>12||mon<1)<br />
{<br />
cout<<"\nWRONG ENTRY";<br />
<br />
goto again;<br />
}<br />
<br />
cout<<"\n\n\t\t\t\tYEAR "<<yy<<"\n\n";<br />
<br />
switch(mon)<br />
{<br />
case 1:cout<<"\n\n\t\t\t\tJANUARY\n\n";break;<br />
case 2:cout<<"\n\n\t\t\t\tFEBRUARY\n\n";break;<br />
case 3:cout<<"\n\n\t\t\t\tMARCH\n\n";break;<br />
case 4:cout<<"\n\n\t\t\t\tAPRIL\n\n";break;<br />
case 10:cout<<"\n\n\t\t\t\tOCTOBER\n\n";break;<br />
case 11:cout<<"\n\n\t\t\t\tNOVEMBER\n\n";break;<br />
case 5:cout<<"\n\n\t\t\t\tMAY\n\n";break;<br />
case 6:cout<<"\n\n\t\t\t\tJUNE\n\n";break;<br />
case 7:cout<<"\n\n\t\t\t\tJULY\n\n";break;<br />
case 8:cout<<"\n\n\t\t\t\tAUGUST\n\n";break;<br />
case 9:cout<<"\n\n\t\t\t\tSEPTEMBER\n\n";break;<br />
case 12:cout<<"\n\n\t\t\t\tDECEMBER\n\n";break;<br />
default:cout<<"\n\nWRONG ENTRY";exit(0);<br />
}<br />
/* Start day of year 1999 i.e. Friday 1st January 1999 */<br />
p=5;<br />
/* Determination of start day of entered year [Calculating from 1999] */<br />
for(r=1999;r<yy;r++)<br />
{<br />
if(r%4==0)<br />
{<br />
if(r%100==0)<br />
{<br />
if(r%400==0)<br />
p=p+2;<br />
else<br />
p++;<br />
}<br />
else<br />
p=p+2;<br />
}<br />
else<br />
p++;<br />
/* Resseting of start variable if last day is reached */<br />
if(p==7)<br />
p=0;<br />
if(p==8)<br />
p=1;<br />
}<br />
/* Start of Month iteration for entered year */<br />
for(mm=0;mm<12;mm++)<br />
{<br />
/* Number of days a month has. Takes from the array defined above */<br />
days=month[mm];<br />
/* Start of days from */<br />
k=0;<br />
/* Setting all values in first row to 0 */<br />
for(z=0;z<7;z++)<br />
calen[0][z]=0;<br />
/* Looping through the rows and columns of calen */<br />
for(i=0;i<5;i++,p=0)<br />
for(j=p;j<7&&k<days;j++)<br />
{<br />
/* Adding of days to the matrix */<br />
calen[i][j]=k+1;<br />
k++;<br />
/* Checking for finish of days */<br />
if(k==days&&i==4&&j<7)<br />
{<br />
/* Setting of remaining values to 0 */<br />
for(p=j+1;p<7;p++)<br />
calen[i][p]=0;<br />
}<br />
/* Putting values on first row if matrix is finished */<br />
if(k<days&&i==4&&j==6)<br />
{<br />
for(p=0;p<7&&k<days;p++,k++)<br />
calen[0][p]=k+1;<br />
j=p-1;<br />
}<br />
/* Setting of j to -1 when days are finished */<br />
if(k==days&&i==4&&j==6)<br />
{<br />
j=-1;<br />
}<br />
/* Special Check if days finish in 4th row e.g. 2009 february */<br />
if(k==days&&i==3&&j==6)<br />
{<br />
/* Setting of final row to 0 */<br />
for(p=0;p<7;p++)<br />
calen[4][p]=0;<br />
}<br />
}<br />
/* Resetting of start day for next month */<br />
p=j;<br />
/* Returning of loop if desired month is found */<br />
if(mm+1==mon)<br />
return;<br />
}<br />
}<br />
/* Displays the values of Calen array */<br />
void calen::display()<br />
{<br />
/* Printing of day names */<br />
cout<<"\n\tSUN\tMON\tTUE\tWED\tTHU\tFRI\tSAT\n\n";<br />
/* Start of loop of rows */<br />
for(i=0;i<5;i++)<br />
{<br />
/* Start of loop of columns */<br />
for(j=0;j<7;j++)<br />
cout<<"\t"<<calen[i][j];<br />
cout<<"\n\n";<br />
}<br />
<br />
getch();<br />
}</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Screenshot of the Program:</span></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-61912947896338580602011-06-25T14:51:00.000-07:002011-10-07T03:19:12.519-07:00C++ Program of The Integral Of Every Terms<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Integral Of Every Terms</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description of the Program: This program displays the integral of each term of expression.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">In the screenshot below, I entered 5 terms that I would like to integrate and the five values of coefficients and exponents. Then, it displayed the whole term of expression that I have entered and the integral of the expression in fraction and in decimal. </span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://3.bp.blogspot.com/-CTvt3-coZNo/TgSI3AsssmI/AAAAAAAAAFg/FaQeNYwHyJI/s1600/integral%2Bterms.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://3.bp.blogspot.com/-CTvt3-coZNo/TgSI3AsssmI/AAAAAAAAAFg/FaQeNYwHyJI/s400/integral%2Bterms.jpg" width="357" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include <windows.h><br />
#include <iostream.h><br />
#include <math.h><br />
#include <string.h><br />
#include <cstring.h><br />
#include <conio.h><br />
<br />
double coeff1[100]={0};<br />
double exponent1[100]={0};<br />
int b;<br />
void dual_swap(double&amp;a,double&amp;b,double&amp;x,double&amp;y)<br />
{double c,d;<br />
c=a;<br />
a=b;<br />
b=c;<br />
d=x;<br />
x=y;<br />
y=d;<br />
}<br />
<br />
int main()<br />
{<br />
string num_coeff;<br />
cout&lt;&lt;"How many terms would you like to integrate: "; cin&gt;&gt;b;<br />
<br />
<br />
for(int x=0;x<b;x++) cout="" {="">&lt;&lt; "\n\nEnter the value of coefficient "&lt;<x+1>&lt;&lt;": \t\t"; cin &gt;&gt; coeff1[x];<br />
cout &lt;&lt; "\nEnter the value of exponent "&lt;<x+1>&lt;&lt;": \t\t"; cin &gt;&gt; exponent1[x];<br />
}<br />
<br />
<br />
for(int aa=0;aa<b;aa++) as="0;as&lt;b;as++)" for(int="" if(exponent1[as]="" {="">exponent1[as+1]&amp;&amp;as+1<b)><br />
dual_swap(exponent1[as],exponent1[as+1],coeff1[as],coeff1[as+1]);<br />
}<br />
}<br />
<br />
<br />
cout &lt;&lt; "\n\n\nYou have entered: \n";<br />
for(int x=0;x<b;x++)><br />
{cout&lt;&lt; coeff1 [x]&lt;&lt; "x^" &lt;&lt; exponent1[x];<br />
<br />
if(x!=b-1)<br />
cout&lt;&lt; " + ";<br />
}<br />
<br />
cout&lt;&lt; "\n\n\nYour new integral in fraction: \n";<br />
for(int x=0;x<b;x++)><br />
{<br />
cout&lt;&lt;"("&lt;&lt; coeff1[x] &lt;&lt; "/" &lt;&lt; exponent1[x] + 1&lt;&lt; ")x^" &lt;&lt; exponent1[x] + 1;<br />
if(x!=b-1)<br />
cout&lt;&lt; " + ";<br />
}<br />
<br />
cout&lt;&lt; "\n\n\nOr in decimal: \n";<br />
for(int x=0;x<b;x++)><br />
{<br />
cout&lt;&lt;"("&lt;&lt; (coeff1[x]) /(exponent1[x] + 1)&lt;&lt; ")x^" &lt;&lt; exponent1[x] + 1;<br />
if(x!=b-1)<br />
cout&lt;&lt; " + ";<br />
}<br />
<br />
getch();<br />
return 0;<br />
}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-62941096421017488542011-06-25T14:49:00.000-07:002011-10-07T03:18:47.562-07:00C++ Program of The Definite Integral<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Definite Integral Calculator</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">By: Marco Scandurra</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description of the Program: This code calculates definite integrals numerically using the Riemann sum.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">The program is set to a default integrand function F(x)=Exp[x/3+2]. You can change this function to whatever you want in the code. The code returns the numerical value of the integral of F(x) between 'a' and 'b' with 5 decimal digits. </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">In the screenshot below, I entered the first limit of this integrand function from 3 to 5 which is equal to 57.1073 and then, I reversed the limit of this function from 5 to 3 which is just the negative of the first result. </span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://3.bp.blogspot.com/-2VOHNt5qLYI/TgRca4gBzEI/AAAAAAAAAEo/W47D3S73hrs/s1600/definite%2Bintegral.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="http://3.bp.blogspot.com/-2VOHNt5qLYI/TgRca4gBzEI/AAAAAAAAAEo/W47D3S73hrs/s400/definite%2Bintegral.jpg" width="400" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include<iostream.h><br />
#include<math.h><br />
<br />
const double n=1000000;<br />
double f(double x);<br />
//double upp1(double p, double q);<br />
//double upp2(double p, double q);<br />
int main()<br />
{<br />
char answ;<br />
double t,j;<br />
double a,b;<br />
cout<<"\t______________________________________________\n";<br />
cout<<"\t***DEFINITE INTEGRAL CALCULATOR***\n";<br />
cout<<"\t \n";<br />
cout<<"\t By: Marco Scandurra\n";<br />
cout<<"\t______________________________________________\n";<br />
cout<<endl;<br />
cout<<endl;<br />
cout<<"\t This program estimates definite integrals\n"; <br />
cout<<"\t numerically using the Riemann sum. \n"; <br />
cout<<endl;<br />
cout<<"\t The integrand is now set to F(x)= exp(x/3 + 2)"<<endl;<br />
cout<<"\t You can chance the integrand in the code.\n";<br />
cout<<endl;<br />
do{<br />
cout<<"\t Enter integration limits from 'a' to 'b': ";<br />
cin>>a;cin>>b;cin.ignore();<br />
double g=0;<br />
for(j=1;j<=n;j++)<br />
{<br />
g=g+( f(a+(b-a)/n*j) * (b-a)/n );<br />
}<br />
cout<<endl;<br />
cout<<"\a \t Integral= "<<g<<endl;<br />
cout<<endl;<br />
cout<<"Again? (y/n): ";cin>>answ;<br />
}while(answ=='y');<br />
<br />
cin.get();<br />
return 0;<br />
}<br />
double f(double x)// This is the integrand function, feel free to change it!<br />
{<br />
return ( exp(x/3+2) );<br />
}<br />
//double upp1(double p, double q)<br />
//{<br />
//return( floor( top*(q-p)/f(q) ) );<br />
//}<br />
//double upp2(double p, double q)<br />
//{<br />
//return( floor( top*f(q)/(q-p) ) );<br />
//}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-24102339809649081062011-06-25T14:46:00.000-07:002011-10-07T03:18:16.364-07:00C++ Program of The Derivatives and Integrals<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Calculus - Derivatives and Integrals<br />
By: Steven Cherry <br />
Description: This program simply prompts the user to do either a derivative or an integral. It asks then for coefficients and exponents, and finally prints the result.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As you can see in the first sc</span><span style="font-size: small;">reenshot below, I entered first 1 for derivative, 3 for three coefficients, and three values of the coefficients and exponents of the expression. Then, the whole expression that I have entered will appear, and finally, the derivative of the expression.</span></div><div style="font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;"></span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="http://4.bp.blogspot.com/-l-2z0iPB1Fo/TgRj6IIBZ-I/AAAAAAAAAEw/k9xNS-9QMtU/s1600/derivative%2Bor%2Bintegral1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://4.bp.blogspot.com/-l-2z0iPB1Fo/TgRj6IIBZ-I/AAAAAAAAAEw/k9xNS-9QMtU/s400/derivative%2Bor%2Bintegral1.jpg" width="306" /></a></span></div><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> In the second sc</span><span style="font-size: small;">reenshot below, I entered first 2 for integral, 3 for three coefficients, and three values of the coefficients and exponents of the expression. Then, the whole expression that I have entered will appear, and finally, the integral of the expression.</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-_YylX3Fh3cM/ThkqO1M4-AI/AAAAAAAAAKI/esL7l3o7VqQ/s1600/derivative%2Bor%2Bintegral2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://3.bp.blogspot.com/-_YylX3Fh3cM/ThkqO1M4-AI/AAAAAAAAAKI/esL7l3o7VqQ/s400/derivative%2Bor%2Bintegral2.jpg" width="306" /></a></div><input name="IL_RELATED_TAGS" type="hidden" value="1" /><br />
<span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include <iostream.h><br />
#include <math.h><br />
#include <string.h><br />
#include <cstring.h><br />
// some global variables to help save space - we'll be using these a lot.<br />
// coeff = coefficient<br />
double coeff1;<br />
double coeff2;<br />
double coeff3;<br />
double exponent1;<br />
double exponent2;<br />
double exponent3;<br />
// derivatives!<br />
void fun_derivative()<br />
{<br />
string num_coeff;<br />
while (num_coeff != "4") // keep user in this menu until they leave.<br />
{<br />
// I love these menus.<br />
cout << "\n\n**********************"<br />
<< "\n\n*DERIVATIVES*"<br />
<< "\n\nMonomial or polynomial?"<br />
<< "\n 1. 1 coefficient"<br />
<< "\n 2. 2 coefficients"<br />
<< "\n 3. 3 coefficients"<br />
<< "\n 4. Return to previous screen"<br />
<< "\n\nEnter choice: ";<br />
cin >> num_coeff;<br />
<br />
if (num_coeff == "1")<br />
{<br />
cout << "\n\nEnter value of coefficient: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent: ";<br />
cin >> exponent1;<br />
// here we're just showing what they entered and what the new<br />
// derivative is.<br />
// formula: f(x) = x^r --> f'(x) = rx^(r-1)<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1<br />
<< "\n\nYour new derivative is: "<br />
<< exponent1 * coeff1 << "x^" << exponent1 - 1 << endl;<br />
}<br />
else if (num_coeff == "2")<br />
{<br />
cout << "\n\nEnter value of coefficient 1: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent 1: ";<br />
cin >> exponent1;<br />
cout << "\n\nEnter value of coefficient 2: ";<br />
cin >> coeff2;<br />
cout << "\nEnter value of exponent 2: ";<br />
cin >> exponent2;<br />
// same as above, just twice as long!<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1 << " + "<br />
<< coeff2 << "x^" << exponent2<br />
<< "\n\nYour new derivative is: "<br />
<< exponent1 * coeff1 << "x^" << exponent1 - 1 << " + "<br />
<< exponent2 * coeff2 << "x^" << exponent2 - 1 << endl; <br />
}<br />
else if (num_coeff == "3")<br />
{<br />
cout << "\n\nEnter value of coefficient 1: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent 1: ";<br />
cin >> exponent1;<br />
cout << "\n\nEnter value of coefficient 2: ";<br />
cin >> coeff2;<br />
cout << "\nEnter value of exponent 2: ";<br />
cin >> exponent2;<br />
cout << "\n\nEnter value of coefficient 3: ";<br />
cin >> coeff3;<br />
cout << "\nEnter value of exponent 3: ";<br />
cin >> exponent3;<br />
// same again, 3x the length. See why global variables are good?<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1 << " + "<br />
<< coeff2 << "x^" << exponent2 << " + "<br />
<< coeff3 << "x^" << exponent3<br />
<< "\n\nYour new derivative is: "<br />
<< exponent1 * coeff1 << "x^" << exponent1 - 1 << " + "<br />
<< exponent2 * coeff2 << "x^" << exponent2 - 1 << " + "<br />
<< exponent3 * coeff3 << "x^" << exponent3 - 1 << endl;<br />
}<br />
}<br />
return;<br />
}<br />
// integrals!!<br />
void fun_integral()<br />
{<br />
string num_coeff2;<br />
cout.precision(10);<br />
while (num_coeff2 != "4")// keep user in this menu until they leave.<br />
{<br />
cout << "\n\n**********************"<br />
<< "\n\n*INTEGRALS*"<br />
<< "\n\nMonomial or polynomial?"<br />
<< "\n 1. 1 coefficient"<br />
<< "\n 2. 2 coefficients"<br />
<< "\n 3. 3 coefficients"<br />
<< "\n 4. Return to previous screen"<br />
<< "\n\nEnter choice: ";<br />
cin >> num_coeff2;<br />
<br />
if (num_coeff2 == "1")<br />
{<br />
cout << "\n\nEnter value of coefficient: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent: ";<br />
cin >> exponent1;<br />
// here we're showing the user what they entered,<br />
// and then the resulting integration of that.<br />
// formula: x^n dx = x^(n+1) / (n+1) + C<br />
// if they enter -1 as n, it won't give an error, but <br />
// they ought to know it's incorrect.<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1<br />
<< "\n\nYour new integral is: ("<br />
<< coeff1 << "/" << exponent1 + 1 <br />
<< ")x^" << exponent1 + 1 << endl;<br />
}<br />
else if (num_coeff2 == "2")<br />
{<br />
cout << "\n\nEnter value of coefficient 1: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent 1: ";<br />
cin >> exponent1;<br />
cout << "\n\nEnter value of coefficient 2: ";<br />
cin >> coeff2;<br />
cout << "\nEnter value of exponent 2: ";<br />
cin >> exponent2;<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1 << " + "<br />
<< coeff2 << "x^" << exponent2<br />
<< "\n\nYour new integral is: ("<br />
<< coeff1 << "/" << exponent1 + 1 <br />
<< ")x^" << exponent1 + 1 << " + ("<br />
<< coeff2 << "/" << exponent2 + 1<br />
<< ")x^" << exponent2 + 1 << endl;<br />
}<br />
else if (num_coeff2 == "3")<br />
{<br />
cout << "\n\nEnter value of coefficient 1: ";<br />
cin >> coeff1;<br />
cout << "\nEnter value of exponent 1: ";<br />
cin >> exponent1;<br />
cout << "\n\nEnter value of coefficient 2: ";<br />
cin >> coeff2;<br />
cout << "\nEnter value of exponent 2: ";<br />
cin >> exponent2;<br />
cout << "\n\nEnter value of coefficient 3: ";<br />
cin >> coeff3;<br />
cout << "\nEnter value of exponent 3: ";<br />
cin >> exponent3;<br />
cout << "\n\nYou entered: "<br />
<< coeff1 << "x^" << exponent1 << " + "<br />
<< coeff2 << "x^" << exponent2 << " + "<br />
<< coeff3 << "x^" << exponent3 <br />
<< "\n\nYour new integral is: ("<br />
<< coeff1 << "/" << exponent1 + 1 <br />
<< ")x^" << exponent1 + 1 << " + ("<br />
<< coeff2 << "/" << exponent2 + 1<br />
<< ")x^" << exponent2 + 1 << " + ("<br />
<< coeff3 << "/" << exponent3 + 1<br />
<< ")x^" << exponent3 + 1 << endl;<br />
}<br />
}<br />
return;<br />
}<br />
int main()<br />
{<br />
string menu_choice;<br />
while (menu_choice != "4")// keep user in this menu until they leave.<br />
{<br />
cout << "\n\n**********************"<br />
<< "\n\n 1. Derivative"<br />
<< "\n 2. Integral" <br />
<< "\n 3. Not used yet"<br />
<< "\n 4. Exit"<br />
<< "\n\nEnter choice: ";<br />
cin >> menu_choice;<br />
<br />
if (menu_choice == "1")<br />
{<br />
fun_derivative();<br />
}<br />
<br />
else if (menu_choice == "2")<br />
{<br />
fun_integral();<br />
}<br />
} <br />
<br />
return 0;<br />
}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-78594139471040901252011-06-25T14:43:00.000-07:002011-10-07T03:17:46.142-07:00C++ Program of The Factor Of A Number<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Get the factor!</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">By: Vinicius Josh Fortuna</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description: This program shows the factors of a number and tests whether it is a prime number or not.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Below is the screenshot of the program. One of the example that I entered is number 888, then, the factor of this number is 2*2*2*3*37. I also entered the number 2 and 5 which displayed a prime number and can't be factor out.</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: center;"><a href="http://3.bp.blogspot.com/-RFld7lUJgFs/TgRmf95Jk4I/AAAAAAAAAFA/8zO3UwAH5VA/s1600/factor.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="286" src="http://3.bp.blogspot.com/-RFld7lUJgFs/TgRmf95Jk4I/AAAAAAAAAFA/8zO3UwAH5VA/s400/factor.jpg" width="400" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;">#include <stdio.h></div><div style="font-family: Georgia,"Times New Roman",serif;">#include <math.h></div><div style="font-family: Georgia,"Times New Roman",serif;">int main()</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> int number; /* The number read */</div><div style="font-family: Georgia,"Times New Roman",serif;"> int gpf; /* Greatest possible factor */</div><div style="font-family: Georgia,"Times New Roman",serif;"> int factor;</div><div style="font-family: Georgia,"Times New Roman",serif;"> enum { FALSE, TRUE } isPrime;</div><div style="font-family: Georgia,"Times New Roman",serif;"> do</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;">printf("Enter the number to be factor or 0 to end: ");</div><div style="font-family: Georgia,"Times New Roman",serif;">scanf("%d", &number);</div><div style="font-family: Georgia,"Times New Roman",serif;">if(number!=0)</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> isPrime = TRUE;</div><div style="font-family: Georgia,"Times New Roman",serif;"> gpf = floor(sqrt(number));</div><div style="font-family: Georgia,"Times New Roman",serif;"> for(factor=2; factor <= gpf; factor++)</div><div style="font-family: Georgia,"Times New Roman",serif;">while(number%factor==0 && number!=1)</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> if(isPrime)</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;">printf("%d = %d", number, factor);</div><div style="font-family: Georgia,"Times New Roman",serif;">isPrime = FALSE;</div><div style="font-family: Georgia,"Times New Roman",serif;"> }</div><div style="font-family: Georgia,"Times New Roman",serif;"> else</div><div style="font-family: Georgia,"Times New Roman",serif;">printf(" * %d", factor);</div><div style="font-family: Georgia,"Times New Roman",serif;"> number = number/factor;</div><div style="font-family: Georgia,"Times New Roman",serif;">}</div><div style="font-family: Georgia,"Times New Roman",serif;"> if(isPrime)</div><div style="font-family: Georgia,"Times New Roman",serif;">printf("%d is a prime number.", number);</div><div style="font-family: Georgia,"Times New Roman",serif;"> else if(number!=1)</div><div style="font-family: Georgia,"Times New Roman",serif;"> printf(" * %d", number);</div><div style="font-family: Georgia,"Times New Roman",serif;"> printf("\n\n");</div><div style="font-family: Georgia,"Times New Roman",serif;">}</div><div style="font-family: Georgia,"Times New Roman",serif;"> }while(number!=0);</div><div style="font-family: Georgia,"Times New Roman",serif;"> return 0;</div><div style="font-family: Georgia,"Times New Roman",serif;">}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-41431849584284846392011-06-25T14:41:00.000-07:002011-10-07T03:11:01.225-07:00C++ Program That Converts A Number Into Words<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Number Into Words Converter<br />
By: Ammar Ahmed<br />
Description: This program displays the Arabic Number in words or descriptive form like 5222 = Five Thousand Two Hundred Twenty Two</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As you can see in the screenshot below, I entered the number 99999,then, it displayed the numbers in thousands, hundreds, tens and ones. Also, it displayed their corresponding words, Ninety Nine Thousand Nine Hundred Ninety Nine. You must </span><span style="font-size: small;">input number ranges from 0-99999.</span><span style="font-size: small;"> </span></div><div style="font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;"></span><br />
<div class="separator" style="clear: both; text-align: center;"><span style="font-size: small;"><a href="http://4.bp.blogspot.com/-EwewnfHYr24/TgWnsnSW2QI/AAAAAAAAAFw/cyFCGxvcBZQ/s1600/number%2Bto%2Bwords.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="312" src="http://4.bp.blogspot.com/-EwewnfHYr24/TgWnsnSW2QI/AAAAAAAAAFw/cyFCGxvcBZQ/s400/number%2Bto%2Bwords.jpg" width="400" /></a></span></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program: </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include<iostream.h><br />
char *ones[10]={" One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"};<br />
char *seconds[10]={" Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen"};<br />
char *tens[10]={" Ten"," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety"};<br />
void main()<br />
{<br />
int number,res,terminate=1;<br />
long int a,b,c,d,e;<br />
while(terminate!=0)<br />
{<br />
cout << "Enter the number between 0-99999 : ";<br />
cin >> number;<br />
while(number<0 || number >100000)<br />
{<br />
cout << endl << "Error please enter the numbers between 0-99999 : ";<br />
cin >> number;<br />
}<br />
a = number - (number%10000);<br />
b = (number%10000) - (number%1000);<br />
c = (number%1000) - (number%100);<br />
d = (number%100) - (number%10);<br />
e = number%10;<br />
cout << "Numbers : " << a << " " << b << " " << c << " " << d << " " << e << endl;<br />
if(number==0)<br />
{<br />
cout << endl << " Zero";<br />
}<br />
if((a+b)==10000)<br />
{<br />
cout << tens[0];<br />
}<br />
if((a+b) > 10000 && (a+b) < 20000)<br />
{<br />
res = ((a+b)/1000)%10 - 1;<br />
cout << seconds[res] << " " << " Thousand";<br />
}<br />
if(a>10000)<br />
{<br />
res = (a/10000)-1;<br />
cout << tens[res];<br />
}<br />
if((a+b)%10000==0 && (a+b) > 99)<br />
{<br />
cout << " Thousand";<br />
}<br />
if((a+b)%10000!=0 && ((a+b)<10000 || (a+b)>20000))<br />
{<br />
res = b/1000 -1;<br />
cout << ones[res] << " " << " Thousand";<br />
}<br />
if((a+b+c)%1000 != 0)<br />
{<br />
res = c/100 -1;<br />
cout << ones[res] << " " << " Hundred";<br />
}<br />
if(d == 0 && e != 0)<br />
{<br />
res = e-1;<br />
cout << ones[res];<br />
}<br />
if(d == 10 && e != 0)<br />
{<br />
res = e-1;<br />
cout << seconds[res];<br />
}<br />
if((d+e)%10 == 0 && (d+e) != 0)<br />
{<br />
res = d/10 - 1;<br />
cout << tens[res];<br />
}<br />
if((d+e) > 20 && (d+e)%10 != 0)<br />
{<br />
res = d/10 - 1;<br />
cout << tens[res] << " " << ones[e-1];<br />
}<br />
if(number==100000)<br />
{<br />
cout << " (Above the range!!!) ";<br />
}<br />
cout << endl << "For running again press 1 or 0 for Exit : ";<br />
cin >> terminate;<br />
cout << endl;<br />
}<br />
}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-24194567202611254292011-06-25T14:39:00.000-07:002011-07-09T23:06:31.909-07:00C++ Program of Quadratic Equation<span style="font-size: small;">Name: Quadratic Equation Solver<br />
By: Cenelia Gonzales</span><br />
<span style="font-size: small;"> Description: This program can be use to solve Quadratic Equation or second-order polynomial equation with one variable "X".</span><br />
<br />
<span style="font-size: small;">Below is the screenshot of the program. The quadratic equation is in the form of A(X^2)+BX+C=0. I entered below the equation, X^2+4X-12=0, with </span><span style="font-size: small;">their coefficients,</span><span style="font-size: small;"> A=1, B=4, and C=-12. Then, it displayed the two roots of the equation which is 2 and -6.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-ZB5TntodElc/TgWrZgxPrJI/AAAAAAAAAF8/b6FP2uA1DB0/s1600/quadratic%2Bequation.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="293" src="http://1.bp.blogspot.com/-ZB5TntodElc/TgWrZgxPrJI/AAAAAAAAAF8/b6FP2uA1DB0/s400/quadratic%2Bequation.jpg" width="400" /></a></div><input name="IL_RELATED_TAGS" type="hidden" value="1" />//Below are the Codes of the Progam:</span><br />
<br />
<div class="scrollbox">#include <iostream.h><br />
#include <math.h><br />
<br />
#define sqr(x) (x)*(x)<br />
#define clrscr() system("cls");<br />
<br />
int main()<br />
{<br />
<br />
cout << "\t\t\tQUADRATIC EQUATION FORM:\n\n";<br />
cout << "\t\t\t A(X^2)+BX+C=0\n\n";<br />
cout << "ENTER COEFFICIENTS:\n";<br />
float A, B, C, Delta;<br />
cout << " A = ";<br />
cin >> A;<br />
cout << " B = ";<br />
cin >> B;<br />
cout << " C = ";<br />
cin >> C;<br />
cout << endl;<br />
if(A == 0 && B != 0)<br />
{<br />
cout << "THIS EQUATION IS A FIRST DEGREE EQUATION\n";<br />
cout << "THE SOLUTION IS: " << -C/B << endl;<br />
}<br />
else if(A == 0 && B == 0)<br />
{<br />
cout << "THIS EQUATION HAS NO SOLUTION";<br />
}<br />
else<br />
{<br />
Delta = sqr(B) - 4*A*C;<br />
if(Delta < 0)<br />
{<br />
cout << "THIS EQUATION DONT HAVE ANY REAL ROOTS";<br />
}<br />
else if(Delta == 0)<br />
{<br />
cout << "THIS EQUATION HAVE A SINGLE ROOT: " << -B/(2*A) << endl;<br />
}<br />
else<br />
{<br />
cout << "THIS EQUATION HAVE TWO REAL ROOTS" << endl;<br />
<br />
float X1 = (-B + sqrt(Delta)) / (2 * A);<br />
float X2 = (-B - sqrt(Delta)) / (2 * A);<br />
<br />
cout << " X1 = " << X1 << endl;<br />
cout << " X2 = " << X2 << endl;<br />
}<br />
}<br />
<br />
<br />
cout << "\nTHANKS FOR USING THIS PROGRAM!" << endl;<br />
cin.get();<br />
cin.get();<br />
return 0;<br />
}</div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-73583453428640289752011-06-25T14:36:00.000-07:002011-10-07T02:38:38.931-07:00C++ Program of The Tic-tac-toe Game<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Tictactoe</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description: This is a program of tictactoe game. A game played by two players who alternately mark squares in a grid with O's or X's. The winner will be the first to get three marks in a row, column or diagonal. In this program, the player should enter number 1 up to 9.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Picture below is the first screenshot wherein you will enter the names of the player. I entered juan for player1 and pedro for player2.</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://3.bp.blogspot.com/-owT9GWwxjcc/TgMJ4cYABSI/AAAAAAAAADw/YScxD42lhYY/s1600/tictactoes1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="340" src="http://3.bp.blogspot.com/-owT9GWwxjcc/TgMJ4cYABSI/AAAAAAAAADw/YScxD42lhYY/s400/tictactoes1.jpg" width="379" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">The second screenshot below is juan's turn, wherein, he needs to enter one number from the remaining number 4,6,7,8,and 9.</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://1.bp.blogspot.com/-f6rizJU-sIQ/TgMJ4QFK6gI/AAAAAAAAAD4/vkK4_S3GFs8/s1600/tictactoes2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="http://1.bp.blogspot.com/-f6rizJU-sIQ/TgMJ4QFK6gI/AAAAAAAAAD4/vkK4_S3GFs8/s400/tictactoes2.jpg" width="400" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As we can see in the third screenshot below, juan wins! Because he is the one who first get three marks (X mark) in a diagonal form.</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://2.bp.blogspot.com/-QeXDFqp7Gyw/TgMJ4qQiRuI/AAAAAAAAAEA/5h_fc8aHr2o/s1600/tictactoes3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="309" src="http://2.bp.blogspot.com/-QeXDFqp7Gyw/TgMJ4qQiRuI/AAAAAAAAAEA/5h_fc8aHr2o/s400/tictactoes3.jpg" width="400" /></a></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">#include <iostream.h></span><br />
<span style="font-size: small;">#include <conio.h></span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">int main()</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;">char tik_tak[3][3]={'1','2','3','4','5','6','7','8','9'},XOX,player1[20],player2[20]; //declaration of array with defaults value</span><br />
<span style="font-size: small;">int value,get[100]={1000},identify=0,stoper=0;</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">cout<<"Enter Player 1 Name : ";</span><br />
<span style="font-size: small;"> cin>>player1;</span><br />
<span style="font-size: small;">cout<<"Enter Player 2 Name : ";</span><br />
<span style="font-size: small;"> cin>>player2;</span><br />
<br />
<span style="font-size: small;">for(int genloop=0;genloop<100;genloop++) //general looping</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;">clrscr(); //clear each loop</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> cout<<"\n\n\n\n\n\n";</span><br />
<span style="font-size: small;"> for(int xloop=0;xloop<3;xloop++) //output the defaults value first</span><br />
<span style="font-size: small;"> { cout<<"\t\t\t";</span><br />
<span style="font-size: small;"> for(int yloop=0;yloop<3;yloop++)</span><br />
<span style="font-size: small;"> {</span><br />
<span style="font-size: small;"> cout<<tik_tak[xloop][yloop]<<"\t";</span><br />
<span style="font-size: small;"> }</span><br />
<span style="font-size: small;"> cout<<"\n\n";</span><br />
<span style="font-size: small;"> }</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> if(identify%2==0) { cout<<player1<<",it's your turn...."; } // if s/2=0 the that turn is on a player while s/2!=0 then its on the others turn</span><br />
<span style="font-size: small;">else if(identify%2!=0) { cout<<player2<<",it's your turn...."; }</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">cout<<"\n\n\n\n\n\n";</span><br />
<span style="font-size: small;">cin>>value; //enter value from 1-9</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">int counter=0;</span><br />
<span style="font-size: small;"> //each loop qa resets its value to 0</span><br />
<span style="font-size: small;">for(int yaloop=0;yaloop<100;yaloop++) //checking if array d is being return</span><br />
<span style="font-size: small;"> if(value==get[yaloop])</span><br />
<span style="font-size: small;"> counter=1;</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">if(counter==0) // if not returned then</span><br />
<span style="font-size: small;"> {</span><br />
<span style="font-size: small;"> identify++; //s is a counter of each loop</span><br />
<span style="font-size: small;">if(identify%2==0) { XOX='O'; } // if s/2=0 the that turn is on a player while s/2!=0 then its on the others turn</span><br />
<span style="font-size: small;">else if(identify%2!=0){ XOX='X'; }</span><br />
<span style="font-size: small;"> //replace the array value</span><br />
<span style="font-size: small;"> if(value==1) tik_tak[0][0]=XOX;</span><br />
<span style="font-size: small;">else if(value==2) tik_tak[0][1]=XOX;</span><br />
<span style="font-size: small;">else if(value==3) tik_tak[0][2]=XOX;</span><br />
<span style="font-size: small;">else if(value==4) tik_tak[1][0]=XOX;</span><br />
<span style="font-size: small;">else if(value==5) tik_tak[1][1]=XOX;</span><br />
<span style="font-size: small;">else if(value==6) tik_tak[1][2]=XOX;</span><br />
<span style="font-size: small;">else if(value==7) tik_tak[2][0]=XOX;</span><br />
<span style="font-size: small;">else if(value==8) tik_tak[2][1]=XOX;</span><br />
<span style="font-size: small;">else if(value==9) tik_tak[2][2]=XOX;</span><br />
<span style="font-size: small;"> }</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> //stored the entered value</span><br />
<span style="font-size: small;"> //checking the array if one already won</span><br />
<span style="font-size: small;"> if(tik_tak[0][1]==tik_tak[0][0]&&tik_tak[0][2]==tik_tak[0][0]) {genloop=100; stoper=1;} //b if a player has already w0n</span><br />
<span style="font-size: small;"> else if(tik_tak[1][0]==tik_tak[1][1]&&tik_tak[1][1]==tik_tak[1][2]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[2][0]==tik_tak[2][1]&&tik_tak[2][1]==tik_tak[2][2]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[0][0]==tik_tak[1][0]&&tik_tak[0][0]==tik_tak[2][0]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[0][1]==tik_tak[1][1]&&tik_tak[1][1]==tik_tak[2][1]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[0][2]==tik_tak[1][2]&&tik_tak[1][2]==tik_tak[2][2]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[0][0]==tik_tak[1][1]&&tik_tak[1][1]==tik_tak[2][2]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"> else if(tik_tak[0][2]==tik_tak[1][1]&&tik_tak[1][1]==tik_tak[2][0]) {genloop=100; stoper=1;}</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> get[genloop]=value;</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> for(int yamloop=0;yamloop<9;yamloop++) //checking if nobody wins for draw only</span><br />
<span style="font-size: small;"> if(get[yamloop]==1)</span><br />
<span style="font-size: small;"> for(int yaaloop=0;yaaloop<9;yaaloop++)</span><br />
<span style="font-size: small;"> if(get[yaaloop]==2)</span><br />
<span style="font-size: small;"> for(int yasloop=0;yasloop<9;yasloop++)</span><br />
<span style="font-size: small;"> if(get[yasloop]==3)</span><br />
<span style="font-size: small;"> for(int yadloop=0;yadloop<9;yadloop++)</span><br />
<span style="font-size: small;"> if(get[yadloop]==4)</span><br />
<span style="font-size: small;"> for(int yafloop=0;yafloop<9;yafloop++)</span><br />
<span style="font-size: small;"> if(get[yafloop]==5)</span><br />
<span style="font-size: small;"> for(int yagloop=0;yagloop<9;yagloop++)</span><br />
<span style="font-size: small;"> if(get[yagloop]==6)</span><br />
<span style="font-size: small;"> for(int yahloop=0;yahloop<9;yahloop++)</span><br />
<span style="font-size: small;"> if(get[yahloop]==7)</span><br />
<span style="font-size: small;"> for(int yajloop=0;yajloop<9;yajloop++)</span><br />
<span style="font-size: small;"> if(get[yajloop]==8)</span><br />
<span style="font-size: small;"> for(int yakloop=0;yakloop<9;yakloop++)</span><br />
<span style="font-size: small;"> if(get[yakloop]==9)</span><br />
<span style="font-size: small;"> {genloop=100; stoper=0;}</span><br />
<span style="font-size: small;">}</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">clrscr(); //clear the screen</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> cout<<"\n\n\n\n\n\n"; //output the defaults value first</span><br />
<span style="font-size: small;"> for(int xloop=0;xloop<3;xloop++)</span><br />
<span style="font-size: small;"> { cout<<"\t\t\t";</span><br />
<span style="font-size: small;"> for(int yloop=0;yloop<3;yloop++)</span><br />
<span style="font-size: small;"> {</span><br />
<span style="font-size: small;"> cout<<tik_tak[xloop][yloop]<<"\t";</span><br />
<span style="font-size: small;"> }</span><br />
<span style="font-size: small;"> cout<<"\n\n";</span><br />
<span style="font-size: small;"> }</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">if(stoper==1)</span><br />
<span style="font-size: small;">{if(identify%2!=0) { cout<<player1<<",you win!!!!!!"; } // if s/2=0 the that turn is on a player while s/2!=0 then its on the others turn</span><br />
<span style="font-size: small;">else if(identify%2==0){ cout<<player2<<",you win!!!!!!"; }</span><br />
<span style="font-size: small;">} //b if a player has win</span><br />
<span style="font-size: small;">else if (stoper==0)</span><br />
<span style="font-size: small;">cout<<"Sorry ,,, it's draw!!\n Nobody wins!!!";</span><br />
<span style="font-size: small;">getch();</span><br />
<span style="font-size: small;">}</span></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-81971329363640556502011-06-25T14:29:00.000-07:002011-10-07T01:57:16.451-07:00C++ Program of The Database or the Infomation System of the Students<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Student Information System</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Created By: Mr. Jake Rodriguez Pomperada, MAED-Instructional Technology</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description: This program displays the database or the information system of the student you have added.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Below is the first screenshot of this program when you RUN your codes. It displays the choices, numbered from 1 up to 5. Just select the number that you want... </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"> </span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://4.bp.blogspot.com/-tR9JKdQ9Yqk/TgMOENCCrNI/AAAAAAAAAEI/ioy2jdE0UaY/s1600/database1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="171" src="http://4.bp.blogspot.com/-tR9JKdQ9Yqk/TgMOENCCrNI/AAAAAAAAAEI/ioy2jdE0UaY/s400/database1.jpg" width="400" />.</a></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;"><br />
</span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;">As you can see in the picture below, I entered number 2 to list or view the records that has been entered in the database. </span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><a href="http://3.bp.blogspot.com/-z41BKRWp_oA/TgMOEDVV2PI/AAAAAAAAAEQ/CXlckmZW2rg/s1600/database2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="http://3.bp.blogspot.com/-z41BKRWp_oA/TgMOEDVV2PI/AAAAAAAAAEQ/CXlckmZW2rg/s400/database2.jpg" width="382" /> </a></div><div style="font-family: Georgia,"Times New Roman",serif;"> <span style="font-size: small;"> </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">//Below are the Codes of the Program:</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;">#include <iostream.h><br />
#include <stdio.h><br />
#include <string.h><br />
#include <stdlib.h><br />
#include <conio.h><br />
#include <iomanip.h><br />
<br />
<br />
main() {<br />
FILE *fp, *ft;<br />
char another, choice;<br />
<br />
struct student {<br />
char first_name[50], last_name[50];<br />
char course[100];<br />
int section;<br />
};<br />
<br />
struct student e;<br />
char xfirst_name[50], xlast_name[50];<br />
long int recsize;<br />
<br />
fp=fopen("users.txt","rb+");<br />
<br />
if (fp == NULL) {<br />
fp = fopen("users.txt","wb+");<br />
<br />
if (fp==NULL)<br />
{<br />
puts("Cannot open file");<br />
return 0;<br />
}<br />
}<br />
<br />
<br />
recsize = sizeof(e);<br />
<br />
while(1) {<br />
system("cls");<br />
<br />
cout << "\t\t====== STUDENT INFORMATION SYSTEM ======";<br />
cout <<"\n\n Created By: Mr. Jake Rodriguez Pomperada, MAED-IT";<br />
cout << "\n\n";<br />
cout << "\n \t\t\t 1. Add Records";<br />
cout << "\n \t\t\t 2. List Records";<br />
cout << "\n \t\t\t 3. Modify Records";<br />
cout << "\n \t\t\t 4. Delete Records";<br />
cout << "\n \t\t\t 5. Exit Program";<br />
cout << "\n\n";<br />
cout << "\t\t\t Select Your Choice :=> ";<br />
fflush(stdin);<br />
choice = getche();<br />
switch(choice)<br />
{<br />
case '1' :<br />
fseek(fp,0,SEEK_END);<br />
another ='Y';<br />
while(another == 'Y' || another == 'y')<br />
{<br />
system("cls");<br />
cout << "Enter the Firt Name : ";<br />
cin >> e.first_name;<br />
cout << "Enter the Last Name : ";<br />
cin >> e.last_name;<br />
cout << "Enter the Course : ";<br />
cin >> e.course;<br />
cout << "Enter the Section : ";<br />
cin >> e.section;<br />
fwrite(&e,recsize,1,fp);<br />
cout << "\n Add Another Record (Y/N) ";<br />
fflush(stdin);<br />
another = getchar();<br />
}<br />
break;<br />
case '2':<br />
system("cls");<br />
rewind(fp);<br />
cout << "=== View the Records in the Database ===";<br />
cout << "\n";<br />
while (fread(&e,recsize,1,fp) == 1){<br />
cout << "\n";<br />
cout <<"\n" << e.first_name << setw(10) << e.last_name;<br />
cout << "\n";<br />
cout <<"\n" <<e.course << setw(8) << e.section;<br />
}<br />
cout << "\n\n";<br />
system("pause");<br />
break;<br />
<br />
case '3' :<br />
system("cls");<br />
another = 'Y';<br />
while (another == 'Y'|| another == 'y')<br />
{<br />
cout << "\n Enter the last name of the student : ";<br />
cin >> xlast_name;<br />
<br />
rewind(fp);<br />
while (fread(&e,recsize,1,fp) == 1)<br />
{<br />
if (strcmp(e.last_name,xlast_name) == 0)<br />
{<br />
cout << "Enter new the Firt Name : ";<br />
cin >> e.first_name;<br />
cout << "Enter new the Last Name : ";<br />
cin >> e.last_name;<br />
cout << "Enter new the Course : ";<br />
cin >> e.course;<br />
cout << "Enter new the Section : ";<br />
cin >> e.section;<br />
fseek(fp, - recsize, SEEK_CUR);<br />
fwrite(&e,recsize,1,fp);<br />
break;<br />
}<br />
}<br />
cout << "\n Modify Another Record (Y/N) ";<br />
fflush(stdin);<br />
another = getchar();<br />
}<br />
break;<br />
<br />
<br />
case '4':<br />
system("cls");<br />
another = 'Y';<br />
while (another == 'Y'|| another == 'y')<br />
{<br />
cout << "\n Enter the last name of the student to delete : ";<br />
cin >> xlast_name;<br />
<br />
ft = fopen("temp.dat", "wb");<br />
<br />
rewind(fp);<br />
while (fread (&e, recsize,1,fp) == 1)<br />
<br />
if (strcmp(e.last_name,xlast_name) != 0)<br />
{<br />
fwrite(&e,recsize,1,ft);<br />
}<br />
fclose(fp);<br />
fclose(ft);<br />
remove("users.txt");<br />
rename("temp.dat","users.txt");<br />
<br />
fp=fopen("users.txt","rb+");<br />
<br />
cout << "\n Delete Another Record (Y/N) ";<br />
fflush(stdin);<br />
another = getchar();<br />
}<br />
<br />
break;<br />
<br />
case '5':<br />
fclose(fp);<br />
cout << "\n\n";<br />
cout << "\t\t THANK YOU FOR USING THIS SOFTWARE";<br />
cout << "\n\n";<br />
exit(0);<br />
}<br />
}<br />
<br />
<br />
system("pause");<br />
}</div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2537995898135297208.post-9891351994619961542011-06-25T14:25:00.000-07:002011-10-07T02:32:05.542-07:00C++ Program of The Possible Factor of a Number<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name: Possible Factor</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Description: This program displays the possible factors of a number. Enter any number and the possible factors of this number will appear.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Below is the screenshot of this program. Click to see it fully. </span></div><div class="separator" style="clear: both; font-family: Georgia,"Times New Roman",serif; text-align: left;"><span style="font-size: small;"><a href="http://3.bp.blogspot.com/-k5dy-XyLmhc/TgMFfBVx0tI/AAAAAAAAADo/w_M5DoDIgAM/s1600/possible%2Bfactor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="http://3.bp.blogspot.com/-k5dy-XyLmhc/TgMFfBVx0tI/AAAAAAAAADo/w_M5DoDIgAM/s400/possible%2Bfactor.jpg" width="200" /></a></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><input name="IL_RELATED_TAGS" type="hidden" value="1" /></div><div class="scrollbox" style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">As you can see in the picture above, I entered the number 9999 and the possible factors of this number appeared.</span><span style="font-size: small;"> </span><br />
<span style="font-size: small;">//Codes:</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">#include <math.h></span><br />
<span style="font-size: small;">#include <conio.h></span><br />
<span style="font-size: small;">#include <iostream.h></span><br />
<span style="font-size: small;">int main()</span><br />
<span style="font-size: small;">{int b;</span><br />
<span style="font-size: small;">cout<<"Enter the number that you want to get the possible factor: ";</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">cin>>b;</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">for(int x=1;x<=b;x++)</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;">if(b%x==0)</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">cout<<","<<b/x;</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">}</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">getch();</span><br />
<span style="font-size: small;">}</span></div></div>Unknownnoreply@blogger.com