Skip to content

Sample repo of small examples of the basics of C++ and general programming concepts

Notifications You must be signed in to change notification settings

LetMeSeeThatCode/CPP_Basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CPP_Basics

Sample repo of small examples of the basics of C++ and general programming concepts

cpp_switchStatements

Source: codecademy learn C++ module

Prompt: Little Mac is an interplanetary space boxer, who is trying to win championship belts for various weight categories on other planets within the solar system. Write a space.cpp program that helps him keep track of his target weight by:

- It should ask him what his earth weight is.
- Ask him to enter a number for the planet he wants to fight on.
- It should then compute his weight on the destination planet.

Here is the table of conversion:

num Planet Relative Gravity
1 Mercury 0.38
2 Venus 0.91
3 Mars 0.38
4 Jupiter 2.34
5 Saturn 1.06
6 Uranus 0.92
7 Neptune 1.19

cpp_logicalOperators

Source: codecademy learn C++ module

Prompt: Let’s try a challenging problem that will put all your brain cells to the test.

Write a leap_year.cpp program that:

  - Takes a year as input.
  - Checks to see if the year is a four-digit number.
  - Displays whether or not the year falls on a leap year.

There are 3 criteria that must be taken into account to identify a leap year:

  - If the year can be evenly divided by 4 then it is a leap year, however…
  - If that year can be evenly divided by 100, and it is not evenly divided by 400, then it is NOT a leap year.
  - If that year is evenly divisible by 400, then it is a leap year.

Take some time to research and brainstorm before starting to write the code!

cpp_vectors

Source: codecademy learn C++ module

Write a program to find the sum of even numbers and the product of odd numbers in a vector.

For example:

Suppose we have a vector that is {2, 4, 3, 6, 1, 9}.

Then the program should output:

Sum of even numbers is 12 Product of odd numbers is 27

About

Sample repo of small examples of the basics of C++ and general programming concepts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published