C++ Answers

Questions answered by Experts: 9 913

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!

Search

Write a program using two for loops to produce the following pattern of asterisks



********

********

********

********


Write a c Program that will print the number series vertically on screen:

10 1 9 2 8 3 7 4 6 5


Enter 2 numbers and print them out. Then print the next 10 numbers in the sequence, where the

next number is the sum of the previous two.


Write a C program that generate the number series below.

1 2 4 7 11 16 22 29 37 46


Input N integers(Ask from the user how many nos. he/she wants to input). Determine and

print the sum of all nos., the average of all numbers, how many odd nos. were inputted,

how many even nos. were entered and how many zeroes inputted.


Enter your name (first name, family name) and a number then print that number of copies of

your name.


Write a C++ program that do the following:

• Declare an array of size 10 double.

• Ask the user to enter 10 double and store them in the array.

• Print the maximum element in the array.

• Print all odd numbers in the array.

• Count and print odd numbers in the array.


10, 20, 4, 5, 30, 1, 6, 3, 9, 60, 70, 90



Simulate the recursion for in-order and post order traversal of BST

10. If the variable divisor is not zero, divide the variable dividend by divisor, and



store the result in quotient. If divisor is zero, assign it to the quotient. Then print



all the variables. Assume the dividend and divisor are integer and quotient is a



double.



11. write a program that create the following number patern.



1 2 3 4 5 6 7 8 9



1 2 3 4 5 6 7 8



1 2 3 4 5 6 7



1 2 3 4 5 6



1 2 3 4 5



1 2 3 4



1 2 3 1 2



1



12. Write a program that accepts student mark out of 100, and return the



corresponding letter grade based on the following condition:



if mark is greater than or equal to 90 A



if mark is greater than or equal to 80 and less than 90 B



if mark is greater than or equal to60 and less than 80 C



if mark is greater than or equal to 40 and less than 60 D



if mark is less than 40 F



for other cases NG



N.B write the program using both switch and else-if



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;




LATEST TUTORIALS
APPROVED BY CLIENTS