marți, 11 decembrie 2018

c++ programming part eight



722. Note: The loop never runs, if from the beginning the initial value is greater than
the final value.
723. Note: The cycle is executed once, if the value of the initial variable is equal to
the value of the final variable.
724. Note: Generally, a FOR cycle is executed by a number times equal to final
value minus initial value plus 1.
725. Loops with an unknown number of steps
726. loop "while"
727. It has the general shape:
728. while (condition)
729. statement;

730. The statement run as long as the condition is the true value.
731. Example
732. #include  
733. / * calculating the amount of components of a vector * /
734. int main ()
735. {
736. float a [4] = {2.34, -7.32, 2.5, 73};
737. int i;

738. float s;
739. s = 0;
740. i = 0;
741. while (i <4 nbsp="" p="">742. {
743. s = s + a [i];
744. i = i + 1;
745. }
746. cout << "the sum of the components is" << s << endl;
747. return 0;
748. }
749. #include  
750. int main ()
751. {
752. int n;
753. cout << "Give one
754. number> ";
755. cin >> n;
756. while (n> 0) {
757. cout << n ;
758. --n;
759. - Displays the valueof n and decrements by 1,
760. that is, n = n-1
761. }
762. return 0;
763. }
764. Give one number= 6
765. 6 5 4 3 2 1
try to learn something else that you know
766. Observation:
767. - the loop is never performed if the condition has begun is false
768. - there must be a statement in the body of the loop to modify the condition
value, otherwise we enter the infinite cycle
769. (in the example above, i = i + 1)
770. loop "DO WHILE"
771.
772. It has the general shape:
773. do

774. statement;
775. while (condition)
776. Example:
777. # includes  
778. / * value calculation 5! * /
779. int main ()
780. {
781. int i, n;
782. i = 1;
783.
784. n = 1;
785. do
786. {n = n * i;
787. i = i + 1;
788. }
789. while (i <6 nbsp="" p="">790. cout << "5! has the value "<< n << endl;
791. return 0;
792. }
793. Observation:
794. - the LOOP is executed at least once, regardless of the value of the condition
795. there must be at least one statement in the body of the loop which will
change the condition, otherwise we will enter in infinite cycle
796.
797.
798.
799. I'm working on software that writes software in c and java. Basically, some
options are selected, data names and functions are entered, and the source code
is generated. The software will be in php. reducing programming time by over 60%.
do sex in a different position than the one you
are used to

Niciun comentariu:

Trimiteți un comentariu

Rețineți: Numai membrii acestui blog pot posta comentarii.