Professional Documents
Culture Documents
session 1
Mail : mostaphaashraf1996@gmail.com
* the computer is very stupid , and its language is “0” . “1” , so how we can input data for
it .
Number Systems:
Cont. Number Systems:
1- binary system “base 2”: represents text, computer processor instructions, or any
other data using a two-symbol system. The two-symbol system used is often the binary
number system's 0 and 1.
2- hexadecimal system “base 16 “ : is commonly used by programmers to describe locations
in memory because it can represent every byte, have values from 0-9 and A-F .
3- decimal system “base 10”: Decimal is a term that describes the base-10 number system,
probably the most commonly used number system. The decimal number system consists of
ten single- digit numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The number after 9 is 10. The number
after 19 is 20 and so forth. Additional powers of 10 require the addition of another positional
digit.
4- octal system “base 8 ” : made from binary numbers , for example : 74 in decimal > in
binary is 1001010 > in octal is 112 : 1*8^2 + 1*8^1 + 2*8^0 .
Range of Signed number = -((2^n-1)-1) ~ ((2^n-1)-1)
5- “ \a “ make a bell .
6 – “ \b “ move a back space .
arithmetic operations:
Cin>> ; and Cout<< ;
#include <iostream>
Using namespace std ;
int main (){
string x ; // Booking a 4 bytes in memory
#include <iostream>
using namespace std ;
int main (){
Int x , y , z ;
cin >> x >> y ;
z = x +y ; cout << z <<“\n”;
z = x-y ; cout << z <<“\n”;
z=x*y ; cout << z <<“\n”;
z= x/ y ; cout << z <<“\n”;
z = x%y ; cout << z <<“\n”;
z = x++ + -- y ; cout << z <<“\n”;
x+= 1 ; y -= 2 ;
cout << x << “ ” << y << “\n” ;
system (“pause”); return 0 ;
}
exercise (1) : math calculation by
“math.h”
#include <iostream>
#include<math.h> // it’s a library make an activation for difrrance math operations.
Using namespace std;
Int main(){
Int a , b , c ;
C = sin (a); cout << c << endl; //can use another Trigonometric functions ,cos,tan,asin, etc..
C = abs(a-b); cout << c << endl; // compute absolute values
C = sinh (a) ; cout << c << endl ; // can use another Hyperbolic functions , cosh , tanh , etc..
C = pow(a,b) ; cout << c << “\n”;// can use another power functions , sqrt , cbrt , hypot .
C = exp(b) ; cout << c << “\n”; // can use another Exponential and logarithmic functions .
Return 0 ; }
Problems :
1- Write a C++ program that for a given number of apples, tells the user how many dozens of
apples(s) he has and how many extra apples are left over.
For Example: if the number of apples = 40, the output should be: 3 dozens and 4 apples
2 - Write a C++ program Count Change to count change. Given the number of quarter,
dimes, nickels and cents the program should output the total as a single value in dollars and
cents.
Hint:
For example if we have: 3 quarters, 2 dimes, 1 nickel and 6 cents, the total is 1.06 dollars.
Cont. problems :
3 - The Pythagorean Theorem states that the sum of the squares of the two sides of the right
angle triangle is equal to the square of the hypotenuse.
For example: 3, 4 and 5 are sides of the right angle triangle as they form a Pythagorean
Triple (52 = 42 + 32)
Given 2 numbers, m and n where m >= n, a Pythagorean Triple can be generated by the
following formulae:
a = m^2 – n^2
b = 2mn
c = root ( a^2 + b ^ 2 )
Write a C++ program that prints the values of the Pythagorean Triple generated by the
formulae above, given m and n.
Out Lines:
1- introduction
2 – number systems
3 – Data Types
4- Ascii table
6 – arithmetic operations
7 - cin , cout