This document is a worksheet for a programming fundamentals course, focusing on loops in C++. It includes various programming tasks such as finding the GCF of two numbers, computing the sum of digits, reversing digits, determining prime numbers, and generating Fibonacci series, among others. Additionally, it requires students to write C++ programs for specific outputs and calculations.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
13 views2 pages
Worksheet 4 (Loop)
This document is a worksheet for a programming fundamentals course, focusing on loops in C++. It includes various programming tasks such as finding the GCF of two numbers, computing the sum of digits, reversing digits, determining prime numbers, and generating Fibonacci series, among others. Additionally, it requires students to write C++ programs for specific outputs and calculations.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
MicroLink Information Technology College
Department of Computer Science
CSSE-133 Programming Fundamentals I Worksheet 4 (Loops: do/while/for) 1. Find the Greatest Common Factor [GCF] of two numbers. 2. Compute the sum of the digits of a number. [For example, the sum of the number 437 is 14] 3. Reverse the order of the digits of a number. [For example, 487 in reversed order will be 784 ] 4. Determine whether a number is prime or not. 5. Displays the following design using loop a) * b) * * * c) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 6. Calculate the factorial of any positive number n. 7. Calculate the sum of the first n factorials. [ Sum = 1! + 2! + 3! + … + (N-1) ! + N! ] 8. Calculate the first n Fibonacci Series. N.B A Fibonacci Sequence is a serious whose first and second series is one and subsequent series element is determined by the sum of the preceding two series elements. Partial list of series: 1,1,2,3,5,8,13,21,34, , , In general F1 = F2 = 1 Fn = Fn-1 + Fn-2 for n>2 9. Write a program that reads an integer number from the keyboard, and then displays all square numbers less than or equal to the number. Example: If the user enters 20, the output shall be: 1, 4, 9, 16 10. Write C++ program to the result of the following:
11. Write C++ program to find e from the following series:
e = 1 + x + (x² / 2!) + (x³ / 3!) + … (xª / a!) 12. Write C++ program to print the following figure: * * 1 * 3 3 3 7 7 7 7 7 * 3 3 3 * * 3 13. Write C++ program to read 10 marks, suppose the student pass if all marks greater than or equal 50, and the average greater than or equal 50. If student fails in some courses then print the number of these courses, if student fails in average then print “fail in average”. MicroLink Information Technology College Department of Computer Science CSSE-133 Programming Fundamentals I Worksheet 4 (Loops: do/while/for) 1. Find the Greatest Common Factor [GCF] of two numbers. 2. Compute the sum of the digits of a number. [For example, the sum of the number 437 is 14] 3. Reverse the order of the digits of a number. [For example, 487 in reversed order will be 784 ] 4. Determine whether a number is prime or not. 5. Displays the following design using loop a) * b) * * * c) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 6. Calculate the factorial of any positive number n. 7. Calculate the sum of the first n factorials. [ Sum = 1! + 2! + 3! + … + (N-1) ! + N! ] 8. Calculate the first n Fibonacci Series. N.B A Fibonacci Sequence is a serious whose first and second series is one and subsequent series element is determined by the sum of the preceding two series elements. Partial list of series: 1,1,2,3,5,8,13,21,34, , , In general F1 = F2 = 1 Fn = Fn-1 + Fn-2 for n>2 9. Write a program that reads an integer number from the keyboard, and then displays all square numbers less than or equal to the number. Example: If the user enters 20, the output shall be: 1, 4, 9, 16 10. Write C++ program to the result of the following:
11. Write C++ program to find e from the following series:
e = 1 + x + (x² / 2!) + (x³ / 3!) + … (xª / a!) 12. Write C++ program to print the following figure: * * 1 * 3 3 3 7 7 7 7 7 * 3 3 3 * * 3 13. Write C++ program to read 10 marks, suppose the student pass if all marks greater than or equal 50, and the average greater than or equal 50. If student fails in some courses then print the number of these courses, if student fails in average then print “fail in average”.