Skip to content

Instantly share code, notes, and snippets.

@rszewczyk
rszewczyk / solution1.c
Last active November 7, 2017 21:36
CMSC104 - homework 1
#include <stdio.h>
double calculatePay(double hourlyRate, double hoursWorked)
{
double pay = 0;
if (hoursWorked > 40)
{
pay = hourlyRate * 40 + (hoursWorked - 40) * 1.5 * hourlyRate;
}
@rszewczyk
rszewczyk / assignment.markdown
Last active November 9, 2017 22:18
CMSC 104 Class 17

Class 17 (11/2/2017) Assignment

Create a file called loops2.c.

Part 1.

Write a program that prompts the user to enter a non negative integer. If the user enters a negative value it should inform the user that the number is not negative and re prompt the user to enter a non negative integer. The program should continue to prompt the user until they enter a valid value and then the program should exit.

@rszewczyk
rszewczyk / gcd.c
Last active October 31, 2017 21:31
GCD is C. CMSC 104
#include <stdio.h>
int main()
{
int first = 0;
int second = 0;
printf("Enter the first number: ");
scanf("%d", &first);
printf("Enter the second number: ");
@rszewczyk
rszewczyk / assignment.markdown
Last active November 9, 2017 22:25
class 16

Assignment - Class 16: 10/31/2017

In this assigment you will learn about looping logic in C.

As part of this assigment you will create a program in a file called loops1.c. When you complete the assigment you will submit loops1.c by uploading it to Slack. If you do not finish today, you have until the end of class (6:45pm) on Thursday, 11/2/2017 to turn it in. Note this doesn't necessarily mean you will have time to work on it in class on 11/2. If don't finish today, you should try and finish it before Thursday.

Step 1

Copy and paste the code below into a new file and save it. Give it the name loops1.c.

@rszewczyk
rszewczyk / assignment.markdown
Last active October 19, 2017 22:19
Class 14 - 10/19/2017

Assignment - Class #14 10/19/2017

In this assigment you will learn about strings in C.

As part of this assigment you will create a program in a file called strings.c. When you complete the assigment you will submit strings.c by uploading it to Slack. If you do not finish today, you have until the end of class (6:45pm) on Thursday, 10/26/2017 to turn it in. Note this doesn't necessarily mean you will have time to work on it in class on 10/26. If don't finish today, you should try and finish it before next Thursday.

Step 1

Copy and paste the code below into a new file and save it. Give it the name strings.c. Upload this file to the UMBC Linux server and compile it.

@rszewczyk
rszewczyk / assignment.markdown
Last active October 19, 2017 22:44
CMSC 104 - Fall 2017, Project 1

Project 1

This program is a take home assignment. You must work on this on your own. It is due 10/31/2017 at 11:59EST. Submit your completed assignment to me on Slack (via direct message!)

Write a program that calculates the user's weekly pay for 2 people.

First, it will prompt the user to enter the standard hourly pay rate for the first person, then it will prompt the user to enter the number of hours the first person worked in the week. Your program will then print the amount that the first person will be paid. It will then prompt the user to enter the standard hourly pay rate for the second person, then it will prompt the user to enter the number of hours the second person worked in the week. Your program will then print the amount that the

@rszewczyk
rszewczyk / practice-midterm.markdown
Last active October 19, 2017 18:27
Practice Midterm

Practice Midterm

I apologize for not posting this over the weekend. Because I ended up not making this available, we will do this as the in class activity for today. You don't need to turn it in. I will provide the answers on Thursday and we will spend some time on any questions you might have then.

The questions on this test are meant to be representative of the type and structure of the questions that you will be asked on the midterm and the range of difficulty - not the content of the questions themselves. The content could be the same as what is covered here but it can also include anything listed in any the objectives up to and including class 12. The midterm will consist of about half as many questions as this practice test. The practice test is harder than the midterm.

@rszewczyk
rszewczyk / assignment.markdown
Last active October 17, 2017 06:34
Assignment - Class #12 10/12/2017

Assignment - Class 12: 10/12/2017

In this assigment you will learn about conditional branching logic in C.

As part of this assigment you will create a program in a file called branching.c. When you complete the assigment you will submit branching.c by uploading it to Slack. If you do not finish today, you have until the end of class (6:45pm) on Tuesday, 10/17/2017 to turn it in. Note this doesn't necessarily mean you will have time to work on it in class on 10/17. If don't finish today, you should try and finish it before Tuesday.

Step 1

Copy and paste the code below into a new file and save it. Give it the name branching.c. Upload this file to the UMBC Linux server and compile it. Then run the program to make sure it works.

@rszewczyk
rszewczyk / assignment.markdown
Last active October 17, 2017 06:20
In Class Assignment - 10/10/2017

Assignment - Class #11 10/10/2017

In this assignment you will continue to practice what you learned last class:

  1. Getting input from the user using scanf
  2. Formatting output that is being printed to the screen using printf

You will also gain more practice with using (calling) functions.

Furthermore, you will be introduced to a new set of library functions called math.h

@rszewczyk
rszewczyk / functions.c
Last active October 4, 2017 10:28
UMBC CMSC 104 - Fall 2017 - Solutions for Class 7 & 8 assignments
#include <stdio.h>
double areaOfCircle(double radius)
{
return radius * radius * 3.14;
}
double areaOfSquare(double lengthOfSide)
{
return lengthOfSide * lengthOfSide;