Answer to Question #284603 in C++ for GET

Question #284603



6.write for loop that will produce each of the following sequence  2, 4, 6, ….44




 5, 7, 9,…...45




 The sum of numbers between 2 to 44 inclusive




 The sum of the first 20 numbers in the series 1, 4, 7, 10…




7.Re write the following code fragment using one switch statement




if (ch = = ‘E’|| ch= = ‘e’)




cout<<" this is either the value of ‘E’ or ‘e’";




else if (ch = = ‘A’|| ch= = ‘a’)




cout<<" this is either the value of ‘A’ or ‘a’";




else if (ch = = ‘r’|| ch= = ‘i’)




cout<<" this is either the value of ‘i’ or ‘r’";




else




cout<<" Enter the correct choice";




8.Write a C++ program for the following flowchart. N.B Let the user enter the




initial value of X and Y, finaly your program should return the value of X, Y and




Z.




9.If the originally x=2 ,y=1 and z=1, what are the value of x, y, z after executing the




following code?




Switch(x)




{




case 0 : x = 2;




y =3;




case 1 : x =4;




Default:




y = 3;




x = 1;




1
Expert's answer
2022-01-04T01:10:06-0500
#include <iostream> 
using namespace std; 
int main() { 
 // 1 2 4 8 16
 for(int i=2;i<=44;i=i*2){
      cout<<i<<" ";  } 
cout<<"\n"; 
// 1 2 4 6 10 15
 for(int i=5;i<=45;i=i+i){
      cout<<i<<" ";
  }
     return 0; } 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog