Game programming 1, week 1

Hello world!

Last week (the week of november the 10th) the first programming course began but since this is my first blog post a short introduction may be needed.

My name is Ludvig Normelli and I’m a game design and programming student at Uppsala university campus gotland. I have never blogged before so this is a new experience for me. The idea is that this blog will be a place which feature my thoughts about school projects or just school work in general. That’ll be enough, it’s time to get back to what I did last week.

Programming is something new to me  so there was a lot to take in during this first week. But I feel that I understood almost everything and I finished the exercises with relative ease.

During the first week we talked about:
– Programming
We had a short introduction to programming, in which we went through the history of computers and programming.  We also talked about C++ which is the programming language we are going to use during the course.
Data types and Variables
Operators
Conditional statements and Loop statements
Scope

We got some exercises to do during the week. The following is an example of these exercises and under that you can see my solution.

 

Program 18
– Write a program that gives the following output
– Let the user decide the number of bottles
“… ”
“4 bottles of juice on the wall, one fell down”
“3 bottles of juice on the wall, one fell down”
“2 bottles of juice on the wall, one fell down”
“1 bottles of juice on the wall, one fell down”
“0 bottles of juice on the wall, one fell down”
“No bottles left on the wall!”

My solution:

#include <iostream>
int main(int argc, char* argv[])
{

int A = 0;
std::cout << "Enter the amount of bottles: ";
std::cin >> A;
for (; A > -1; A--)
{
std::cout << A << " bottles of juice on the wall, one fell down" << std::endl;
if (A == 0)
{
std::cout << "No bottles left on the wall" << std::endl;
}
}
std::cin.ignore(1024, '\n');
std::cin.get();
return 0;

}

Thanks for reading!

// Ludvig

 

Leave a comment