write a program that prints Fibnocci series but skip every 3 rd value while

# Write a program that prints fibnocci series but skip

This preview shows page 7 - 12 out of 14 pages.

write a program that prints Fibnocci series but skip every 3 rd value while printing. i.e. 1 1 3 5 13 21 Print up to 20 numbers Procedure/Program: #include <iostream> using namespace std; int main () { int a = 1, b = 1, c, i, counter = 2; cout << a << " " << b << " " ; for (i = 1; i <= 6; i++) { if (counter == 3) counter = 0; counter++; c = a + b; if (counter != 3) { cout << c << " " ; a = b; b = c; } else { a = b; b = c; } } return 0; } Result/Output: Analysis/Conclusion: This is how we program. Task # 7.7:Write output. Procedure/Program: #include <iostream> using namespace std; int main () { int i, n, f; cout << "Enter number(-1 to quit): " ; cin >> n; do { for (i = 1, f = 1; i <= n; i++) { cout << i << endl ; f = f * i; } cout << "Factorial is: " << f << endl ; cout << "Enter number(-1 to quit): " ; cin >> n; } while (n != -1); return 0; } Result/Output: Analysis/Conclusion: This is how we program. Task # 7.8:Write a program in C++using switch statementwhich asks the user to enter day number (1-7) and print the respective day such as day number 1 will display “Monday”. Procedure/Program: #include <iostream> using namespace std; int main () { int num; cout << "Enter day number: " ; cin >> num; switch (num) { case 1: cout << "Monday" ; break ; case 2: cout << "Tuesday" ; break ; case 3: cout << "Wednesday" ; break ; case 4: cout << "Thursday" ; break ; case 5: cout << "Friday" ; break ; case 6: cout << "Saturday" ; break ; case 7: cout << "Sunday" ; break ; default : cout << "Wrong input" ; break ; } return 0; } Result/Output: Analysis/Conclusion: This is how we program. Task # 7.9:Write a program which takes three values from user as integers, verify which value is highest, in middle and lowest and display on screen.Procedure/Program:#include<iostream>usingnamespacestd;intmain(){intv1, v2, v3, max;cout << "Enter first number: "cin >> v1;cout << "Enter second number: "cin >> v2;cout << ; ; ;   #### You've reached the end of your free preview.

Want to read all 14 pages?

• Spring '16
• Return statement, Carriage return, cout, namespace std
• • • 