Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please using visual studio 2015 c++. how to give code and pseudo code. Also, can

ID: 3804119 • Letter: P

Question

Please using visual studio 2015 c++. how to give code and pseudo code. Also, can I have some comment each coding and show me result. thank you :)

Program #1 Since we're now dealing with iteration logic in the labs and lecture, here are some small looping problems for practice. For the first problem in this homework, write a single program that does the following a) prints out the even integers between 2 and 100 b) prints out the integers that are multiples of 3 from 99 down to 3 c) prints out the integers between 2 and 1,048,576 20 that are integer powers of 2. d) prints out the integers between 1,048,576 down to 2 that are integer powers of 2. e) does something new involving loops, different than any of the above. (This is an exercise in being creative. Give yourself a task, and solve it.) For each of these problems, include a counter variable inside the loop that counts how many numbers are printed out. Report that result as well. The results for problems (a) and (b) should be printed out with 10 integers per line, right justified in a 5 byte field. For example, the output for the even integers between 2 and 40 will look like 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 Number of numbers 20

Explanation / Answer

Answer:

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int powoftwo(int n){ //funtion which checks whether the number is power of 2 or not
if(n==0)
return 0;
while(n!=1){
if(n%2!=0)
return 0;
n=n/2;
}
return 1;
}
void powtwo(){
int cnt1=0;
for(long i=2;i<=1048576;i++){
  
if(powoftwo(i)){
cout<<i<<" ";
cnt1++;
}
if(cnt1==10){
cnt1=0;
cout<<endl;
}
}
}
void powtwodown(){
int cnt1=0;
for(long i=1048576;i>=2;i--){
  
if(powoftwo(i)){
cout<<i<<" ";
cnt1++;
}
if(cnt1==10){
cnt1=0;
cout<<endl;
}
}
}
void printmul(){
int cnt1=0;
for(int i=3;i<=99;i++){
if(i%3==0){
cout<<i<<" ";
cnt1++;
}
if(cnt1==10){
cnt1=0;
cout<<endl;
}
}
}
void printeven(){
int cnt=0;
for(int i=2;i<=100;i++){
  
if(i%2==0){
cout<<i<<" ";
cnt++;
  
}
if(cnt==10){
cnt=0;
cout<<endl;
}
}
}
int main(){
  
cout<<"Output of part a"<<endl;
printeven(); //solution of part a
cout<<"Output of part b"<<endl;

printmul(); ///solution of part b
cout<<"Output of part c"<<endl;
powtwo(); //answer of part c
cout<<"Output of part d"<<endl;
powtwodown() ;//answer of part d


return 0;
}

output:

E)

Above the part d in all part loops were incremented but in part d for loop was decrement loop.