0% found this document useful (0 votes)
10 views2 pages

PFC - Workshop 03 & 04: Workshop31 (Workshop31.c) - Write A Program That Performs The Following Tasks

The document provides instructions for 4 programming workshops: 1. Workshop 31 asks the user to input an integer and display it in binary format, calculate the sum of its digits, and find the number with the digits reversed. 2. Workshop 32 asks the user to input 2 numbers m and n, then display all palindromic numbers between them. 3. Workshop 41 asks the user to input a real number x and integer n, then calculate a summation formula and display an unexplained step. 4. Workshop 42 asks the user to design a program that displays a table of prime numbers within a user-specified range in a columnar format, including functions and input validation.

Uploaded by

Phong Nguyễn
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
10 views2 pages

PFC - Workshop 03 & 04: Workshop31 (Workshop31.c) - Write A Program That Performs The Following Tasks

The document provides instructions for 4 programming workshops: 1. Workshop 31 asks the user to input an integer and display it in binary format, calculate the sum of its digits, and find the number with the digits reversed. 2. Workshop 32 asks the user to input 2 numbers m and n, then display all palindromic numbers between them. 3. Workshop 41 asks the user to input a real number x and integer n, then calculate a summation formula and display an unexplained step. 4. Workshop 42 asks the user to design a program that displays a table of prime numbers within a user-specified range in a columnar format, including functions and input validation.

Uploaded by

Phong Nguyễn
Copyright
© © All Rights Reserved
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

PFC - Workshop 03 & 04

Workshop31 (Workshop31.c). Write a program that performs the following tasks:


1. Input an integer number n (if n <=0 then exit), then
2. Display n in binary number format.
3. Re-input n (not check input validation). Calculate sum of all digits of n.
4. Find the number m, which is the reverse of n.

Sample input and output:

Workshop32 (Workshop32.c)
- Write a program to accept 2 integer numbers m and n, where m < n then
- Display all palindrom numbers in the interval [m.n]. (A palindromic number or numeral palindrome
is a number that remains the same when its digits are reversed, e.g. 16461)

Workshop41 (Workshop41.c) Write a program that performs the following tasks:


1. Input a real number x and an integer number n, where n > 5 (If n≤ 5 then prompt a user to
re-enter). Then calculate:
2. S =1.2.3 + 2.3.4 + 3.4.5 + … + (n - 2)(n - 1)n

3.

4.

Workshop42 (Workshop42.c) Table of Primes


Design and code a program that displays a table of prime numbers within a specified range and in
columnar form. Your program prompts for and accepts the number of primes to be displayed, the low
and high value of the range of integers to be considered and the number of primes to be displayed in
any single row.
Design your program according to structured design principles and include a function that can readily
be used in other applications. Do not use any library functions apart from <stdio.h> functions.
Preface your function header with a comprehensive description of the function purpose, the function
parameters and the function return value.
A prime number is a whole number that is divisible by 1 and itself only. 1 is not considered a prime
number.
The output from your program should look something like:
Table of Primes
===============
Lower limit: 0
Upper limit: 175
# of columns: 5

2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
53 59 61 67 71
73 79 83 89 97
101 103 107 109 113
127 131 137 139 149
151 157 163 167 173

Search the Internet for a list of prime numbers to confirm the results of your program

You might also like