Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Monday, June 3, 2013

Some C++ Problems for Beginners (7)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder

-2DimArrayFrom1DimArray.cpp:
Problem Definition:
Supposing that you have the following 1 Dimensional Array called A as a known input:
int A[10] = {1,1,2,5,3,4,9,8,7,1};
 
Fill the Char Array B (char B [10][10]) with the Histogram values taken from the Array A
then Print the Histogram in B
================================================
output:
-------
 
*
*
**
*****
***
****
*********
********
*******
*
 
================================================

[C++]
  1 /*  About The Simple Code "_2DimArrayFrom1DimArray.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3 
  4     This simple code is a free simple: you can redistribute it and/or modify 
  5     it under the terms of the GNU General Public License as published by 
  6     the Free Software Foundation, either version 3 of the License, or 
  7     (at your option) any later version. 
  8   
  9     This program is distributed in the hope that it will be useful, 
 10     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12     GNU General Public License for more details. 
 13   
 14     You should have received a copy of the GNU General Public License 
 15     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 16 
 17 #include <iostream>
 18 using namespace std;       
 19 
 20 /*Problem Definition
 21 Supposing that you have the following 1 Dimensional Array called A as a known input:
 22 int A[10] = {1,1,2,5,3,4,9,8,7,1};
 23 
 24 Fill the Char Array B (char B [10][10]) with the Histogram values taken 
 25 from the Array A then Print the Histogram in B
 26 ================================================
 27 output:
 28 -------
 29 
 30 *
 31 *
 32 **
 33 *****
 34 ***
 35 ****
 36 *********
 37 ********
 38 *******
 39 *
 40 
 41 ================================================
 42 //*///Prototypes
 43 void FillArray(int A[10], char B[10][10]);
 44 void PrintArray(char B[10][10]);
 45 
 46 void main()
 47 {
 48  int A[10] = {1,1,2,5,3,4,9,8,7,1};        
 49  char B [10][10];            
 50 
 51  FillArray(A, B);            
 52  PrintArray(B);             
 53 }
 54 
 55 //Function "FillArray" takes 2 Attributes A --> The input Array & B --> The output Array
 56 //It takes the values from the Array "A" and fill the Output Array "B" with 
 57 //Stars and Spaces to Draw the Histogram
 58 void FillArray(int A[10], char B[10][10] )
 59 {
 60  for(int i = 0; i < 10; i++)         
 61  {
 62   for(int j = 0; j <10; j++)        
 63   {
 64    if( j < A[i])          
 65    {
 66     B[i][j] = '*';         
 67    }
 68    else
 69    {
 70     B[i][j] = ' ';        
 71    }
 72   }
 73  }
 74 
 75 }
 76 
 77 
 78 //Function "PrintArray" takes 1 Attribute B --> The Output Array and prints it
 79 //It Loops over all the Array "B" elements and print them all (The Histogram)
 80 void PrintArray(char B[10][10])
 81 {
 82  for(int i = 0; i < 10; i++)     
 83  {
 84   for(int j = 0; j < 10; j++)    
 85   {
 86    cout<<B[i][j];      
 87   }
 88   cout<<endl;        
 89 
 90  }
 91 
 92 }

download the 2DimArrayFrom1DimArray.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (6)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder
-TwoDimArray.cpp:
Problem Definition:
Write a code fragment that construct a two-dimensional array (name it B) of integers with
5 rows and 5 columns. Then:
-Fill-in the array B to contain the multiplication table from 1 to 5
-Find the sum of the numbers for each row
-Find the sum of all numbers in the array

[C++]
  1 /*  About The Simple Code "TwoDimArray.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3     
  4 
  5     This simple code is a free simple: you can redistribute it and/or modify 
  6     it under the terms of the GNU General Public License as published by 
  7     the Free Software Foundation, either version 3 of the License, or 
  8     (at your option) any later version. 
  9   
 10     This program is distributed in the hope that it will be useful, 
 11     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13     GNU General Public License for more details. 
 14   
 15     You should have received a copy of the GNU General Public License 
 16     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 17 
 18 
 19 #include <iostream>
 20 using namespace std;   
 21 
 22 
 23 /* Problem Definition: ... taken from the Quizes quiz D)d
 24 Write a code fragment that construct a two-dimensional array (name it B) of integers 
 25 with 5 rows and 5 columns. Then:
 26 -Fill-in the array B to contain the multiplication table from 1 to 5
 27 -Find the sum of the numbers for each row
 28 -Find the sum of all numbers in the array
 29 */
 30 
 31 //Prototypes
 32 void InsertIntoArray(int B[5][5]);
 33 void RowSum(int B[5][5]);
 34 void ArraySum(int B[5][5]);
 35 
 36 
 37 void main()
 38 {
 39  int B[5][5];    
 40  InsertIntoArray(B);   
 41  RowSum(B);     
 42  ArraySum(B);    
 43 
 44 }
 45 
 46 
 47 /* 2D Array Structure /*
 48 
 49 1 2 3 4 5
 50 2 4 6 8 10
 51 3 6 9 12 15
 52 4 8 12 16 20
 53 5 10 15 20 25
 54 
 55 */
 56 
 57 //Function InsertIntoArray is a Function that insert the values of 
 58 //the multiplication table from 1 to 5 and print them on the screen
 59 void InsertIntoArray(int B[5][5])
 60 {
 61  cout<<"Full Array"<<endl<<"=_==_==_==_==_==_==_==_==_="<<endl;
 62  for(int i = 0; i<5; i++)    
 63  {          
 64   for (int j = 0; j<5; j++)   
 65   {         
 66   B[i][j] = (i+1) * (j+1);   
 67   cout<<B[i][j];      
 68   } 
 69   cout<<endl;       
 70  }          
 71 }
 72 
 73 //Function RowSum is a Function that Print the Sum of each Row from the 2D Array on the Screen
 74 void RowSum(int B[5][5])
 75 {
 76  cout<<endl<<"Row Sum"<<endl<<"=_==_==_==_==_==_==_==_==_="<<endl;
 77  int sum = 0;         
 78  for(int i = 0; i<5; i++)      
 79  {
 80   for (int j = 0; j<5; j++)     
 81   {
 82   sum += B[i][j];        
 83   }
 84   cout<<sum<<endl;       
 85   sum=0;          
 86  }
 87 }
 88 
 89 
 90 //Function RowSum is a Function that Print the Sum of all the values in the 2D Array on the Screen
 91 void ArraySum (int B[5][5])
 92 {
 93  cout<<endl<<"Array Sum"<<endl<<"=_==_==_==_==_==_==_==_==_="<<endl;
 94  int sum = 0;       
 95  for(int i = 0; i<5; i++)    
 96  {
 97   for (int j = 0; j<5; j++)   
 98   {
 99   sum += B[i][j];      
100   } 
101  }
102  cout<<sum<<endl;      
103 }



download the TwoDimArray.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (5)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder
-ShapesAreas.cpp:
Problem Definition:
Write a program that take from the user "1" if Circle, "2" if Rectangle, "3" if Triangle,
"4" if Square & "5" if Parallelogram
then Calculate and Print the Area of the chosen Shape after taking the inputs from the
user.
Note:
Area of a:
                Circle = π × r2               (read r from the user and consider that π = 3.14)
                Rectangle = w x h                       (read w and h from the user)
                Triangle = 1/2 base x h         (read base and h from the user)
                Square = L2                             (read L from the user)
                Parallelogram = base * h         (read base and h from the user)

[C++]
  1 /*  About The Simple Code "ShapesAreas.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3 
  4     This simple code is a free simple: you can redistribute it and/or modify 
  5     it under the terms of the GNU General Public License as published by 
  6     the Free Software Foundation, either version 3 of the License, or 
  7     (at your option) any later version. 
  8   
  9     This program is distributed in the hope that it will be useful, 
 10     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12     GNU General Public License for more details. 
 13   
 14     You should have received a copy of the GNU General Public License 
 15     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 16 
 17 
 18 #include <iostream>
 19 #define PI 3.14
 20 using namespace std;            
 21 
 22 /*Problem Definition
 23 Write a program that take from the user "1" if Circle, 
 24 "2" if Rectangle, "3" if Triangle, "4" if Square & "5" if Parallelogram
 25 then Calculate and Print the Area of the chosen Shape after taking the inputs from the user.
 26 Note:
 27 Area of a:
 28     Circle = π × r2               (read r from the user and consider that π = 3.14)
 29     Rectangle = w x h    (read w and h from the user)
 30     Triangle = 1/2 base x h  (read base and h from the user)
 31     Square = L2     (read L from the user)
 32     Parallelogram = base * h  (read base and h from the user)
 33 */
 34 
 35 //Prototype(s)
 36 void ReadCalculatePrintArea(int choice);
 37 float CalculateCircleArea(int r);
 38 float CalculateRectangleArea(int w, int h);
 39 float CalculateTriangleArea(int base, int h);
 40 float CalculateSquareArea(int L);
 41 float CalculateParallelogramArea(int base, int h);
 42 
 43 void main()
 44 {
 45  int choice;
 46  cout<<"Please, enter 1 if Circle, 2 if Rectangle, 3 if Triangle, 4 if Square and 5 if Parallelogram : "<<endl;
 47     cin>>choice;             
 48  ReadCalculatePrintArea(choice);         
 49 }
 50 
 51 //ReadCalculatePrintArea is a function that take the Choice from the User then 
 52 //1. Reads the inputs from the user based on the chosen choice
 53 //2. Calls the Specific CalculateArea Function based on the chosen shape
 54 //3. Prints on the screen the Final Area Result taken from the specified Called CalculateArea Function
 55 void ReadCalculatePrintArea(int choice)
 56 {
 57 
 58 float Area;
 59 switch(choice)
 60  {
 61  case 1:                  
 62   int r;                 
 63   cout<<"Please Enter the Radius of the Circle : "<<endl;
 64   cin>>r;                 
 65   Area = CalculateCircleArea(r);           
 66   cout<<"The Area of the specified Circle is : "<<Area<<endl;    
 67   break;
 68 
 69  case 2:                  
 70   int w,h;                
 71   cout<<"Please Enter the Width and the Height of the Rectangle :"<<endl;
 72   cin>>w>>h;                
 73   Area = CalculateRectangleArea(w,h);          
 74   cout<<"The Area of the specified Rectangle is : "<<Area<<endl;   
 75   break;
 76 
 77  case 3:                  
 78   int base,h2;               
 79   cout<<"Please Enter the Base and the Height of the Triangle :"<<endl;
 80   cin>>base>>h2;               
 81   Area = CalculateTriangleArea(base,h2);         
 82   cout<<"The Area of the specified Triangle is : "<<Area<<endl;   
 83   break;
 84 
 85  case 4:                  
 86   int L;                 
 87   cout<<"Please Enter the Lenght of the Square : ";
 88   cin>>L;                 
 89   Area = CalculateSquareArea(L);           
 90   cout<<"The Area of the specified Square is : "<<Area<<endl;    
 91   break;
 92 
 93  case 5:                  
 94   int base2,h3;               
 95   cout<<"Please Enter the Base and the Height of the Parallelogram";
 96   cin>>base2>>h3;               
 97   Area = CalculateParallelogramArea(base2,h3);       
 98   cout<<"The Area of the specified Parallelogram is : "<<Area<<endl;  
 99   break;
100 
101  default:                 
102   cout<<"Invalid Choice";
103   break;
104  }
105 }
106 
107 //CalculateCircleArea is a function that return the Circle Area
108 float CalculateCircleArea(int r)
109 {
110  return PI * r * r;
111 }
112 
113 //CalculateRectangleArea is a function that return the Rectangle Area
114 float CalculateRectangleArea(int w, int h)
115 {
116  return w * h;
117 }
118 
119 //CalculateTriangleArea is a function that return the Triangle Area
120 float CalculateTriangleArea(int base, int h)
121 {
122  return 0.5 * base * h;
123 }
124 
125 //CalculateSquareArea is a function that return the Square Area
126 float CalculateSquareArea(int L)
127 {
128  return L * L;
129 }
130 
131 //CalculateParallelogramArea is a function that return the Parallelogram Area
132 float CalculateParallelogramArea(int base, int h)
133 {
134  return base * h;
135 }

download the ShapesAreas.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (4)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder

-ZeroSmaller.cpp: Problem Definition:
Write a function called ZeroSmaller() that is passed three int arguments by reference and 
then sets the smaller of the three numbers to "0"

[C++]
  1 /*  About The Simple Code "ZeroSmaller.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3 
  4     This simple code is a free simple: you can redistribute it and/or modify 
  5     it under the terms of the GNU General Public License as published by 
  6     the Free Software Foundation, either version 3 of the License, or 
  7     (at your option) any later version. 
  8   
  9     This program is distributed in the hope that it will be useful, 
 10     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12     GNU General Public License for more details. 
 13   
 14     You should have received a copy of the GNU General Public License 
 15     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 16 
 17 
 18 #include <iostream>             
 19 using namespace std;
 20 
 21 /*Problem Definition ... inspired from the sheets Quiz H)D) but a little bit more complex
 22 Write a function called ZeroSmaller() that is passed three int arguments by reference and 
 23 then sets the smaller of the three numbers to "0"
 24 */
 25 
 26 void ZeroSmaller (int &X, int &Y, int &Z);
 27 
 28 void main()
 29 {
 30  int X,Y,Z;
 31  cout<<"Please, Enter the 3 Numbers : "<<endl;
 32  cin>>X>>Y>>Z;          
 33  ZeroSmaller(X,Y,Z);         
 34  cout<<"First Number = "<<X<<endl<<"Second Number = "<<Y<<endl<<"Third Number = "<<Z<<endl;
 35 }
 36 
 37 /*
 38 ZeroSmaller is a function that Set the minimum number of the 3 Inputs numbers to "0"
 39 
 40 e.g.  if 
 41 Inputs:
 42 X = 3, Y = 5, Z = 1 (Minimum)
 43 
 44 Outputs:
 45 X = 3, Y = 5, Z = 0
 46 */
 47 void ZeroSmaller (int &X, int &Y, int &Z)
 48 {  
 51  (X < Y)? ((X < Z)? X = 0 : Z = 0) : ((Y < Z)? Y = 0 : Z = 0);
 52 
 53  /* Another Way to do the function ..Or The normal way *//*
 54           
 55 if(X < Y)
 56  {
 57   if (X < Z)
 58   {
 59    X = 0;
 60   }
 61   else
 62   {
 63    Z = 0;
 64   }
 65  }
 66  else
 67  {
 68   if(Y < Z)
 69   {
 70    Y = 0;
 71   }
 72   else
 73   {
 74    Z = 0;
 75   }
 76  }        
 77 
 78 */
 79  
 80 }



download the ZeroSmaller.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (3)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder

-EquationProblem.cpp:
Problem Definition:
Without Using MATH.h write a program that can solve the following equation and Display
"R" on the screen
R = X^Y + Y^Z - (X + Y)^2

[C++]
  1 /*  About The Simple Code "EquationProblem.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3 
  4     This simple code is a free simple: you can redistribute it and/or modify 
  5     it under the terms of the GNU General Public License as published by 
  6     the Free Software Foundation, either version 3 of the License, or 
  7     (at your option) any later version. 
  8   
  9     This program is distributed in the hope that it will be useful, 
 10     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12     GNU General Public License for more details. 
 13   
 14     You should have received a copy of the GNU General Public License 
 15     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 16 
 17 
 18 #include <iostream>             
 19 using namespace std;            
 20 
 21 /*Problem Definition
 22 Without Using MATH.h write a program that can solve the following equation and Display "R" on the screen
 23 R = X^Y + Y^Z - (X + Y)^2
 24 */
 25 
 26 
 27 float SolveEquation(int X, int Y, int Z);
 28 int Power(int Num, int Pow);
 29 
 30 void main ()              
 31 {
 32  int X,Y,Z;
 33  cout<<"Please enter X, Y and Z : ";
 34  cin>>X>>Y>>Z;             
 35  
 36  float R = SolveEquation(X,Y,Z);         
 37  cout<<"The Result is "<<R;          
 38 }
 39 
 40 
 41 /*SolveEquation is a function that Solve the equation >> R = X^Y + Y^Z - (X + Y)^2 */
 42 float SolveEquation(int X, int Y, int Z)
 43 {
 44  float r = Power(X,Y) + Power(Y,Z) - Power((X+Y),2);    
 45  return r;
 46 }
 47 
 48 /*Power is a function that take a Number and a Power Number and 
 49 returns the Number at the Power of the Power Number (Num^Pow) e.g. 2^3=8 */
 50 int Power(int Num, int Pow)
 51 {
 52  int r=1;
 53 
 54  for(int i = 0; i<Pow; i++)      
 55  {
 56   r*=Num;          
 57  }
 58  return r;          
 59 }

download the EquationProblem.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (1)


Yesterday, I’ve decided to write some simple C++ programs to help beginners to know how to write some code;
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder

1. –DynamicStars.cpp: Problem Definition:
Write a Program that Dynamically draw Stars * from "N" entered by the User to 1
 
e.g. 
 
Input: 3
 
Output:
 
***
**
*

[C++]
  1 /* About The Simple Code "DynamicStars.cpp"
  2 
  3 Copyright (C) 2013 Eng. Mohamed Adel (http://www.med-adel.com)
  4 
  5 This simple code is a free simple: you can redistribute it and/or modify 
  6 
  7 it under the terms of the GNU General Public License as published by 
  8 
  9 the Free Software Foundation, either version 3 of the License, or 
 10 
 11 (at your option) any later version. 
 12 
 13 This program is distributed in the hope that it will be useful, 
 14 
 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 
 16 
 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 18 
 19 GNU General Public License for more details. 
 20 
 21 You should have received a copy of the GNU General Public License 
 22 
 23 along with this program. If not, see <http://www.gnu.org/licenses/>.*/
 24 
 25 #include <iostream>
 26 
 27 using namespace std;
 28 
 29 /*Problem Definition
 30 
 31 Write a Program that Dynamically draw Stars * from "N" entered by the User to 1
 32 
 33 e.g. 
 34 
 35 Input: 3
 36 
 37 Output:
 38 
 39 ***
 40 
 41 **
 42 
 43 *
 44 
 45 */
 46 
 47 void DrawStars(int n);
 48 
 49 void main ()
 50 
 51 {
 52 
 53  int n;
 54 
 55  cout<<"Please enter the max number of stars to be drawn :";
 56 
 57  cin>>n;
 58 
 59  DrawStars(n); 
 60 
 61 }
 62 
 63 
 64 /*DrawStars is a function that draw Stars starting from N till 1 Star*/
 65 void DrawStars(int n)
 66 
 67 {
 68 
 69  for(int i = 0 ; i < n; i++)
 70 
 71  {
 72 
 73   for(int j=0; j < n-i; j++) 
 74   { 
 75    cout<<"*"; 
 76   }
 77 
 78   cout<<endl; 
 79 
 80  }
 81 
 82 }


download the DynamicStars.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Some C++ Problems for Beginners (2)


This Post has some Previous Posts, you can access the first Main Post here: Some C++ Problems for Beginners (1)
The code was written and tested on Visual Studio 2010 –> “Empty Windows Console Application” . if you don’t have Visual Studio, you can get the latest version from :
-Visual C++ 2010 Express:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

note that, you can also use another IDEs like:
-Visual Studio Express 2012 for Windows Desktop: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#product-express-summary
-CodeBlocks: http://sourceforge.net/projects/codeblocks
-GNU C++ compiler GCC(g++): http://gcc.gnu.org/
-MingW GCC port for windows: http://www.mingw.org/
-C++ Builder (Borland): http://www.embarcadero.com/products/cbuilder

1. -AlphabeticalModulus.cpp: Problem Definition:
Write a Program that read 2 Numbers from the user X & Y where 1<= Y <= 9 (if Y is not in
the specified range terminate the program)
Print R = X % Y (R = X Modulus Y) in English Letters

e.g. 
if 
R = 5 --> Print "Five"
 
note: R will always be a value between 0 and 9

[C++]
  1 /*  About The Simple Code "AlphabeticalModulus.cpp"
  2     Copyright (C) 2013  Eng. Mohamed Adel (http://www.med-adel.com)
  3 
  4     This simple code is a free simple: you can redistribute it and/or modify 
  5     it under the terms of the GNU General Public License as published by 
  6     the Free Software Foundation, either version 3 of the License, or 
  7     (at your option) any later version. 
  8   
  9     This program is distributed in the hope that it will be useful, 
 10     but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 12     GNU General Public License for more details. 
 13   
 14     You should have received a copy of the GNU General Public License 
 15     along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
 16 
 17 
 18 #include <iostream>             
 19 using namespace std;
 20 
 21 /*Problem Definition
 22 Write A Program that read 2 Numbers from the user X & Y 
 23 where 1<= Y <= 9 (if Y is not in the specified range terminate the program)
 24 Print R = X % Y (R = X Modulus Y) in English Letters
 25 e.g. 
 26 if 
 27 R = 5 --> Print "Five"
 28 
 29 note: R will always be a value between 0 and 9
 30 */
 31 
 32 char * ConvertToEnglish(int Num);
 33 
 34 
 35 int main ()
 36 {
 37  int X,Y,R;
 38  cout<<"Please Enter X then Y where (1<= Y <=9) :"<<endl;
 39  cin>>X>>Y;
 40  if(Y<1 || Y>9)
 41   {
 42    cout<<"Invalid Y Value";
 43    return 0;
 44   }
 45 
 46  R = X % Y;
 47  cout<<"The Result is : "<<ConvertToEnglish(R)<<endl;
 48  return 1;
 49 }
 50 
 51 
 52 //ConvertToEnglish is a function that convert the integer number to its corresponding 
 53 //English word and returns a Char* (array of chars/string) containing the English word
 54 //e.g. 1 --> One, 2 --> Two, etc...
 55 char * ConvertToEnglish(int Num)
 56 {
 57  switch(Num)
 58  {
 59  case 0:
 60   return "Zero";
 61   break;
 62  case 1:
 63   return "One";
 64   break;
 65  case 2:
 66   return "Two";
 67   break;
 68  case 3:
 69   return "Three";
 70   break;
 71  case 4:
 72   return "Four";
 73   break;
 74  case 5:
 75   return "Five";
 76   break;
 77  case 6:
 78   return "Six";
 79   break;
 80  case 7:
 81   return "Seven";
 82   break;
 83  case 8:
 84   return "Eight";
 85   break;
 86  case 9:
 87   return "Nine";
 88   break;
 89  default:
 90   return "Error";
 91   break;
 92  
 93  }
 94 
 95 }

download the AlphabeticalModulus.cpp  (Commented, Explained Code)

Download all the C++ Simples I’ve created : C++ Problems

Friday, September 28, 2012

What is Enterprise Search?

 

 

-Enterprise Search refers to “Search behind the corporate Firewall” or

It is the Search technology that the organization owns and controls

-Many applications could include search on a company’s website home page and tech support area, or e-commerce shopping sites.

-So Enterprise search engines could be defined as all search engines except the public ones like Yahoo, Google and MSN (BING).

 
  For More Info Please Visit: What is Enterprise Search?  

How do Enterprise Search Engines differ from Web Search Engines?

 


Many of us think that the Search Engines are all the same, but we have to know that Search Engines have different types that are totally Different and that there are many differences between for example the Enterprise Search Engines and the Normal Public Web Search Engines like Google and Bing such as:

 

1. The Enterprises world isn’t just a small Internet: 

–Many Enterprise Search Offering began life as a search engines to power generic Internet Portal Searching, Thus we should assume that if you could handle the internet, then of course you could handle a relatively puny private Enterprise NetworkIn Fact, It’s not true and this assumption is usually false, Thus.. Any Enterprise Search Engine should be customized and adjusted to work well in the non-Internet like networks.

 

2. Technical Differences in Search Requirements and Technologies:

-Aside from the difference in the architecture and data volume between Internet Search and Enterprise Search, There are also differences in how the infrastructure is used and functional requirements such as:

  • There is Usually a right document in the Enterprise Search (Whereas Google for example finds tens of thousands of pages relevant to almost any search you could imagine)
  • Security is Critical: On the Internet, content is public for anyone or everyone who may find it, but companies have many specific security requirements from “Company Confidential” to “Limited Distribution”, there may be sometimes some legal implications if a document is released to the public before a specific time.

3-Taxonomies and Vocabulary are critical: Companies always have a specific vocabulary such as: product names, projects, procedures and policies, Thus.. Taking advantages of these terms unique to the company is critical to making retrieval work better.

 

4-Dates are important:

-Internet search is generally unaware of document dates because content on the internet always lock this info.

e.g. if the corporate search for “Annual Reports” doesn’t return the Most recent document, The Employees will be unhappy for sure.

 

5-Corporate Data has Structure:

In a corporate database and even in web contents, companies have a specific structure that make some results authorized or accessed for some employees and not permitted for some others.

Thus, Enterprise Search Engines have to be able to apply the company’s rules and hierarchy on the outputs returned to the employees.

 

Conclusion:

There are dozens of things that make Enterprise Search Engines suprizingly difficult and that sometimes exceed the strength and size of the Public Engines created to empower the web such as Google, Yahoo and Bing.

 

 
  For More Info Please Visit: Another Difference Between Enterprise Search and Web Search  

Sunday, September 18, 2011

WPF VS Silverlight

 


What is the difference between WPF and Silverlight?

I’ve heard many developers talking about this topic;

Here’s a Good research about WPF VS Silverlight that answers this famous question

done by Eng. Ibraheem Osama Mohamed (MSP Egypt – Helwan Microsoft Tech-Club)

 

 http://j.mp/WPF_vs_SL (PDF Version – 232 KB)

 
  For More Info Please Visit: Helwan Microsoft Tech-Club Page on Facebook  

Wednesday, September 7, 2011

How to install the Windows Phone Developer Tools on Windows Server 2008

 


The Windows Phone Developer Tools are not officially supported on operating systems other than Windows Vista or Windows 7. 

There is a way you can work around the Windows Server 2008 setup block if needed.  Please note that this is not officially supported, so if you try these steps, you are doing so at your own risk.

  1. Download the Windows Phone Developer Tools web installer and save it to your hard drive
  2. Extract the contents of the setup package by running vm_web.exe /x and choosing a path to extract to
  3. Go to the folder you extracted to in step 2 and open the file baseline.dat in notepad
  4. Look for the section named [gencomp7788]
    Note - you have to change this exact section - this is the one that controls the OS version blocking behavior in Windows Phone Developer Tools setup.
  5. Change the value InstallOnLHS from 1 to 0
  6. Change the value InstallOnWin7Server from 1 to 0
  7. Save and close baseline.dat
  8. Run setup.exe /web from the folder you extracted to in step 2
    Note - please make sure that you include the /web command line parameter in step 8.  If you don't, setup will not attempt to download the packages it needs to install, and it will fail to install correctly as a result.
 
  For More Info Please Visit: Aaron Stebner's WebLog  

Monday, September 5, 2011

Installing SQL Server 2008 R2 (SQL Administration Part 2 - 1)

 

Hardware Requirements:

1-For SQL Server 2008 R2 Standard Edition “32 Bit”

a-Processor
-Pentium 1.0 GHZ minimum processing power

-2.0 GHZ or higher “recommended”

b-Operating System:

-XP SP3 or higher

b-Memory

-MIN 1GB.

-4 GB or more“recommended”

-MAX 64 GB

-Express Editions requires 192 MB and recommends 512 MB RAMS


2-For SQL Server 2008 R2 Standard Edition “64 Bit”

a-Processor
-Pentium 1.4 GHZ minimum processing power

-2.0 GHZ or higher “recommended”

b-Operating System:

-XP Professional SP2 64x – Windows Server 2003 SP2 64x or higher

b-Memory

-MIN 1GB.

-4 GB or more“recommended”

-MAX 64 GB

-Express Editions requires 192 MB and recommends 512 MB RAMS



Disk Space Required (32 bit and 64 bit)

verify that you have at least 3.6 GB of available disk space on the system drive for these files before starting the SQL Server installation.

-Database Components (Engine – data files – Replication – Full Text Search): 711 MB

-Analysis Services: +90 MB (Average 345 MB)

-Reporting Services: +120 MB (Average 304 MB)

-Integration Services: +120 MB (Average 591 MB)

-Client Components: +850 MB (Average 1823 MB)

 
  For More Info and to view the other SQL Server 2008 R2 Editions HW and SW Requirements Please Visit: Hardware and software requirements for installing SQL Server 2008 R2  

Wednesday, April 27, 2011

Introduction to SQL Server 2008

 

Hi again,

I’m Mohamed Adel Microsoft Middle East and Africa Data Platform Developer and I'll write a series of blog posts about SQL Server 2008 R2, hope you enjoy this series.

  • Introduction to SQL Server 2008 R2

 

SQL Server Storage:

-524272 TB per DB

-32767 concurrent user connections

-32757 Databases on a server

-up to 2147483647 tables per database

-1024 columns per table

 

SQL Server Versions and history:

-Microsoft and IBM are the first to start The data base development concept @1989

-1998 MS OLAP TOOLS

-2000 SQL Server 2000 (8.0)

-9.0 SQL Server 2005

-10.0 SQL Server 2008

-Virtual Box (SUN Virtual Machine)

 

SQL Server Editions:

 

1-Core Editions (Standard & Enterprise)

 

a- Standard

-Small to large business

-Up to 4 CPU

-Max OS Ram

b-Enterprise

-Enterprise Workloads and BI

-CPU and raM limited by OS

 


2-Specialized Editions

 

a-Workgroup:

-Remote offices
-2 CPU Max
-4 GB Ram MAX

b-Web

-Web application hosting

-4 CPU's MAX

-OS MAX RAM

c-Developer

-licensed for development and testing only
-OS MAX CPUs
-OS MAX RAMs

 


3-Free Editions

 

a-Express Edition:

-Entry level for learning

-1 CPU MAX

-1 GB MAX RAM

-4 GB MAX Database SIZE

b-Compact 3.5

-embedded database for developing desktop and mobile apps
-OS MAX CPUs
-OS Max RAMs

 
 
  For More Info Please Visit: SQL Server 2008 R2 Introduction  

AI-Enabled Risk Scoring for TPPs in Open Banking: A Game Changer for Ecosystem Trust

As Open Banking ecosystems mature globally, traditional banks, fintech startups, and regulators face a growing challenge: how to trust the g...