Machote Programacion Reparado
Machote Programacion Reparado
Programming 1
Bank of Exercise.
Summary This document describes each program with the D. For Loop.
function it performs as well as the flow chart of each with In this program C ++ should be coded to work
pseudocode. It shows inputs, processes and outputs. correctly and describe its function.
Index of Terms Else, If, while, C ++, Flow digrama, E. For.
pseudocode, inputs, processes, outputs. This Program to print half pyramid using *.
Modify this program to print half pyramid using
I. INTRODUCTION.
numbers.
If: It is used to assert a true condition.
ForLoop: This statement is used to add cycles as the counter i. F. do...while Loop.
While: While a condition is true this statement is executed, Encode this program in C ++ and explain what its
otherwise it executes another condition. function.
Goto salto: It is used to skip a sentence in case it is true or not.
Break: It is a break from the program.
M. Else
Given a number makes the sum and prints if it is
odd or even at the same time.
III. METHODOLOGY
IV. RESULTS
In this are placed the codes of the programs run and Pseudocode
that is what each one performs. 1. Start
2. Insert an integer number
A. If else statement. 3. Save number
In this program given an integer prints if it is 4. If the number n> 0 the number is negative, on
the contrary the number is positive
negative or positive. 5. End
#include <iostream>
using namespace std; B. If, if else and Nested ifelse.
int main()
{ In this given program any letter prints if it is vocal
int number;
cout << "Enter an integer: ";
or consonant.
cin >> number; #include <iostream>
if (number >= 0) using namespace std;
{ int main()
cout << "You entered a positive integer: {
" << number << endl; Float n1 , n2, n3;
} Cout<<enter three numbers:;
else Cin>> n1>>n2>>n3
{ If((n1>=n2)&&(n1>=n3))
cout << "You entered a negative integer: Cout<<largest number :<<n1;
" << number << endl; Else if((n21>=n1)&&(n2>=n3))
} Cout<<largest number :<<n2;
cout << "This line is always printed."; Else
return 0; Cout<<largest number: <<n3;
} return 0;
Enters. Procces. Outputs. }
Number. Condition Show numbers Enters. Procces. Outputs.
Number>=0 posive and Three Numbers . Comparison. Shows if it
negative number largest
Pseudocode
1. Start
2. Enter number
3. Save number
4. Use cycle four(MQ i=1; i<=range; ++i) to print
the result
5. End
Pseudocode
1. Start
2. Enter 3 number E. For.
3. A,B,C Save
4. If A> B entonses A> C the largest number is A In this program C ++ should be coded to work
otherwise the large number is C, if B> C correctly and Modify this program to print half
entonses B otherwise C is greater pyramid using numbers.
5. End #include <iostream>
using namespace std;
D. For Loop. int main()
Given a number the program makes the {
int i,j, rows;
multiplication table of the given number. cout << "Enter number of rows: ";
#include<iostream> cin >> rows;
Pseudocode
1. Start
2. Enter number interger
3. Save number
4. Performs sum process
5. Make a compareison if
6. If the result is add, to print
7. If not if will not give the result until the
negative number
8. End
G. C++ break.
In this program makes the sum of all the positive
numbers entered by the user, stopping when
inserting a negative number.
#include <iostream>
using namespace std;
int main()
{
Pseudocode float number, sum = 0.0;
1. Start // test expression is always true
2. Enter number of rows while (true)
3. Save number {
4. Use cycle while (MQ i=1; i<=N; ++i) to print cout << "Enter a number: ";
result cin >> number;
5. End if(number<0.0)
{
F. do...while Loop. goto salto;
}
In this program makes the sum of all the positive {
numbers entered by the user, stopping when sum += number;
}
inserting 0 and makes the total sum. }
#include <iostream> salto:
using namespace std; sum=sum;
int main() cout << "Suma = " << sum;
{ return 0;
float number, sum = 0.0; }
do Enters. Procces. Outputs.
{ Number. Sum. Result of
cout<<"Enter a number: "; addition.
cin>>number;
sum += number;
Pseudocode
1. Start Pseudocode
2. Enter number interger 1. Start
3. Save number 2. White (MQ i<1; 1<=10; ++i)
4. Performs sum process 3. If %2=0 is true not print number
5. Make a compareison if 4. If false show number
6. If N<0.o print the result of the sum in the case 5. End
contrary not print result
7. If not if will not give the result until the
negative number I. For.
8. End
Makes the sum of an entered number (example 1 +
2 + 3 ... n) stopping when entering the number that
the user entered.
H. C++ continue. #include<iostream>
using namespace std;
Prints the sequence of 1 100 with the exception of int main()
even numbers. {
#include <iostream> int N, i, SUMA=0;
using namespace std; cout<<"Introduce un numero entero: ";
int main() cin>>N;
{ for (int i=1; i<=N; ++i)
for (int i = 1; i <= 100; ++i) {
{ SUMA = SUMA + i;
if ( i % 2 == 0 ) cout <<"\nLa suma es:"<<SUMA-
{ i<<"+"<<i<<"="<<SUMA;
continue; }
} if (N<=0)
cout << i << "\t"; {
} cout<<"El valor introducido no es
return 0; mayor a 0: ";
} }
Enters. Procces. Outputs.
i. Division. Result of the return 0;
divisin. }
Enters. Procces. Outputs.
N. Sum. Result of
i. addition.
Result of
addition.
Pseudocode
1. Start
2. Enter number while (Mq i=1; i<=N; ++i)
3. For add = add=i
4. To print the result
5. The end
J. Float.
Makes the sum of the given exponents and divides
them between the same exponent, showing at the
end the total sum. Pseudocode
#include<iostream> 1. Start
using namespace std; 2. Enter number
int main() 3. Save number
{ 4. To what power do you want to raise that number
float N, E, i, power=1, division=0, sum=0; 5. Save number
cout<<"Enter a number integer: "; 6. For (i=1; i<=E; ++i)
cin>>N; 7. Operation are carried out
cout<<"To what power do you want to raise that 8. Prin result
number: "; 9. End
cin>>E;
for (int i=1; i<=E; ++i)
{ For.
power = power*N;
division = power/(i);
Given an exponent does the power dow of the
sum = sum + division; result.
cout <<"\nThe power #include<iostream>
is:"<<N<<"^"<<i<<"="<<power<<"\nThe division is: using namespace std;
"<<power<<"/"<<i<<"="<<division<<"\nThe sum is: "<<sum- int main()
division<<"+"<<division<<"="<<sum; {
} int N, E, i, power=2, sum=0;
if (E<=0) cout<<"Enter a whole number to evaluate: ";
{ cin>>N;
cout<<"The value entered is not greater than cout<<"To what power do you want to raise that
0: "; number?: ";
cin>>E;
} for (int i=1; i<=E; ++i)
{
return 0; power = power*N;
} sum = sum + power;
Enters. Procces. Outputs. cout <<"\nThe power
N. Power. Result of power. is:"<<N<<"^"<<i<<"="<<power<<"\nThe sum is: "<<sum-
E. Division. Result of power<<"+"<<power<<"="<<sum;
i. Suma. divisin. }
if (E<=0)
Pseudocode
1. Start
2. Enter number
3. Save number Pseudocode
4. To what power do you want to sum that number 1. Start
5. Save number 2. Enter a number to evaluate
6. For ((int i=1; i<=E; ++i)) 3. Save number
7. Show the result sum of power + power 4. To what power do you want to raise that number
8. Prin result 5. Save number
9. End 6. For (i=1; i<=E; ++i)
7. Operation are carried out
8. Prin result
L. For. 9. End
if ( i %2 !=0 )
{
sumodd=sumodd+i;
}
else
{
sumpair=sumpair+i;
}
}
cout<<"\nThe sum of the pairs is: "<<sumpair;
cout<<"\nThe sum of the odd is: "<<sumodd;
return 0;
}
Enters. Procces. Outputs.
N. Sum. Result of
addition.
Pseudocode
1. Start
2. Enter number integer
3. Save number
4. While (MQ i=1; i<=N; ++i)
5. If is true add pair
6. If is false add sum to print the pair +i
7. To print of the add sum +i
8. End
V. CONCLUSIONES
With this program bank it is possible to say that it
is important to know the different sentences in order
to be able to solve the different problems of each
program. We require different programs such as C
++ and Visio to solve them.