0% found this document useful (0 votes)
165 views1 page

Lab2 Selection Structures

This document outlines 3 programming assignments for a computer fundamentals lab. The first asks students to write a program that takes 4 numbers as input and outputs them in ascending order. The second asks students to write a program that determines if a line defined by 2 coordinates has a positive slope, negative slope, is horizontal, or vertical. The third asks students to write a program that takes a month, day and year as input, checks if it is a valid date, and outputs the date and its corresponding zodiac sign.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views1 page

Lab2 Selection Structures

This document outlines 3 programming assignments for a computer fundamentals lab. The first asks students to write a program that takes 4 numbers as input and outputs them in ascending order. The second asks students to write a program that determines if a line defined by 2 coordinates has a positive slope, negative slope, is horizontal, or vertical. The third asks students to write a program that takes a month, day and year as input, checks if it is a valid date, and outputs the date and its corresponding zodiac sign.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CMPE 20012: COMPUTER FUNDAMENTALS AND PROGRAMMING

LABORATORY2: SELECTION STRUCTURES (INDIVIDUAL)

1. CREATE A C++ PROGRAM THAT THE USER WILL INPUT 4 NUMBERS AND THE OUTPUT
IS TO ARRANGE IN ASCENDING ORDER.

EX:
INPUT: 12 15 16 17
OUTPUT: 12 15 16 17

INPUT:25 21 16 30
OUTPUT: 16 21 25 30

INPUT: 18 10 13 11
OUTPUT: 10 11 13 18

2. CREATE A C++ PROGRAM THAT THE USER WILL INPUT 2 COORDINATES TO REPRESENT
A LINE IN A CARTESIAN PLANE AND THE OUTPUT IS TO DETERMINE THE ILLUSTRATION
OF THE LINE. (POSITIVE SLOPE/NEGATIVE SLOPE/HORIZONTAL LINE/VERTICAL LINE)

EX:
INPUT: INPUT: INPUT:
X1: 2 X1: 2 X1: 5
Y1: 2 Y1: 2 Y1: 5
X2: 4 X2: 2 X2: 3
Y2: 4 Y2: 5 Y2: 5

OUTPUT: OUTPUT: OUTPUT:


POSITIVE SLOPE VERTICAL LINE HORIZONTAL LINE

3. CREATE A C++ PROGRAM THAT THE USER WILL INPUT 3 NUMBERS (MONTH, DAY AND
YEAR) AND THE OUTPUT IS TO PRINT THE DATE IF IT IS VALID AND ITS CORRESPONDING
ZODIAC SIGN.

EX:
INPUT: INPUT:
MONTH: 12 MONTH: 6
DAY: 25 DAY: 1
YEAR: 1942 YEAR: 2021

OUTPUT: OUTPUT:
DECEMBER 25, 1942 JUNE 1, 2021
CAPRICORN GEMINI

INPUT: INPUT:
MONTH: 13 MONTH: 3
DAY: 22 DAY: 35
YEAR: 2007 YEAR: 2010

OUTPUT: OUTPUT:
INVALID DATE INVALID DATE

You might also like