Algoriothm For C Language Programming for Beginers.pptx

columbanojustin24 12 views 19 slides Feb 26, 2025
Slide 1
Slide 1 of 19
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19

About This Presentation

Algoriothm For C Language Programming for Beginers


Slide Content

CS102: Programming Jhosua B. Mostar Joey Colala Prince Vladimier Delos Reyes

Algorithm of first 15 Numbers A.) Write an algorithm to produce the first 15 numbers of this series: 1, 1, 2, 3, 5, 8, 13, 21, …

Start A = 1 Display A B = 15? e B = 0 C = 0 B = 0 D = A Stop B + 1 A = A + C Display A C = D e Yes No

Algorithm that raise to any power B.) Write an algorithm that raise any number to any power.

Start Input A B = 1? e Input B P = A Power Yes No P = P *A B - 1 e Display P Stop

Days before Christmas C.) Make a formula that computes the number of days before Christmas given any date.

Start e Input M Input D Input Month (as Jan, Feb, Marc, ect . Input Day in a numeric form e X > 0 X = M - D Jan = 359 Feb = 328 Mar = 300 Apr = 270 May = 240 June = 209 July = 179 Aug = 148 Sept = 117 Oct = 86 Nov = 56 Dec = 25 e No Yes Christmas passed Display X Stop Stop

Types of Parallelogram D.) Given the sides of a parallelogram, write an algorithm to determine its type.

Start L == W? Yes No Input L Input W Length Width Square Rectangle Stop Stop

Types of Parallelogram E.) During a summer you get a job as a DJ at a small radio that only plays teenagers’ music. To make your program more attractive, you run a contest: you will receive 10 phone calls from the public, and afterwards, you will award a thoughtful prize to the oldest member of your audience. Note the following: you receive one call at a time, you do not know when the next call will occur, you are not allowed to disclosed the age at any moment.

Start Caller = 0 A ≤ 10 ? e Older = 0 A = 1 No Yes e Display Ölder Stop B = 0 Input Caller Caller ≥ Older Yes No Older = Caller B = A A = A + 1 B = A f A = A + 1 f Caller that is older than the previous caller, Age Age Number of Caller

Determining Leap Years F.) Write the Algorithm that will determine if the given year is a leap year.

Start Input x Does x has Remainder? Total = x / 4 Stop Yes No Total = x / 100 Display “Not a leap year” Does X has remainder? Yes No Total = x / 400 Stop Display “Not a leap year” Does X has remainder? Yes No Stop Display “Not a leap year” Stop Display “Leap year”

Finding X and Y 4.) Given the formula y = 0.5x^2-3, describe the steps needed to get the list of Y –values, for a range of X-values from -3 to +3.

Start X = -4 Y = 0 X = X + 1 X = 4 Yes No A = X * X B = 0.5 * A Display Y e e Stop Y = B - 3 A = 0 B = 0

Finding the values of Y H.) Given the table on the right, find the formula that relates variable X with variable Y and describe the steps needed to get the list of Y-values. X Y -6 -18.5 -4 -12.5 -2 -6.5 -0.5 2 5.5 4 11.5 6 17.5

Start X = -8 Y = 0 X = X + 2 X = 8 Yes No Y = 3 * X Y = Y - 0.5 Display Y /n e e Stop

Breaking the Formula I.) Break down the formula in several steps.

W = B * B X = 4 * A * C Y=W-X Z= √Y R2 = -B + Z R1= -B - Z PROD2 = R2 / A PROUD1 = R 1 / A PRINT PROD1\N PRINT PROD2\N STOP START Input A Input B Input C PRINT PROD2\N
Tags