You are on page 1of 2

switch (experision)

{
case 1:
break;
case2:
break;
....
default:

}
int a;
switch (a)
{

case 1: print (Monday); break;


case 2: print tusday); break;
...
default :
print its out of limitation
}

exprision ? stegment1:stegment2;
int a, b;
cin>>a>>b;

int max =(a>b)?a:b;

maximum using above syntx

=======================
we have 3 way for implement circle
it is very matter that we know when we should use circle
---when we have one or more one command that need run for many time we use circle
ok?
an example
print the number between 1 and 1000
cout;
for(int i=1; i<=1000; i++)
{
cout<<i;
}
our steps:
---- how many should we repeat
--
1- for
2- while
3-do while
---- for
for(intial and define variable ; condition ; reduce or increasse variable)
{
commands;
}

====================
get a number and calc how many divisble it has --> 6 has 4 divisble
complete number like --> 6 (1,2,3) and if (1+2+3) is complete number
---
reach all number between 100 to 1000 that are divisible on 5 and 7; like 35 is the
number that 35%7==0 and 35%5==0
70 105 i140
// get a number and calculate its factoriel ---> 5=5*4*3*2*1
//print 10 series of Fibunanchi --- 1 1 2 3 5 8 13 21

=======================================================
For Inside For
for (int i=1;i<10;i++)
for(int j=1;j<i;

=======================================================
1
3 2
6 5 4
10 9 8 7
-------------
1
3 5
7 9 11
-------------
1
2 1
3 2 1
4 3 2 1
------------
1
2 3
4 5 6
-------------
1
1 2 1
1 2 3 2 1
------------------
*
* *
* * *

You might also like