This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//monte_hall.c | |
//Monte Hall Problem is adapted from Rosetta Code | |
// Content is available under GNU Free Documentation License 1.2 unless otherwise noted. | |
#include <stdlib.h> | |
#include <time.h> | |
#include <stdio.h> | |
#define GAMES 3000000 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simulate.c | |
/** | |
* At University High School, 80% of the students are expected to get at | |
* least a 4 on their APCSP exam. The program below is intended to | |
* simulate this result with n students, and display the number | |
* of students who received a 4 or a 5. | |
**/ | |
#include <cs50.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implement binary search function | |
#include <cs50.h> | |
#include <stdio.h> | |
#define NUMBERS 9 | |
bool bin_search(int value, int values[], int size); | |
int main(void) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complete the insertion_sort function | |
#include <cs50.h> | |
#include <stdio.h> | |
// function prototypes | |
void insertion_sort(int arr[], int n); | |
void print_array(int arr[], int n); | |
// size of array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complete the selection_sort function | |
#include <cs50.h> | |
#include <stdio.h> | |
// function prototypes | |
void selection_sort(int arr[], int size); | |
void print_array(int arr[], int size); | |
// size of array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complete the bubble_sort function | |
#include <cs50.h> | |
#include <stdio.h> | |
// function prototypes | |
void bubble_sort(int arr[], int size); | |
void print_array(int arr[], int size); | |
// size of array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cs50.h> | |
#include <stdio.h> | |
int get_positive_int(string prompt); //This is called the prototype. It tells the compiler to look for the function below the main function. Note the ; | |
int main(void) | |
{ | |
int n = get_positive_int("Enter a positive number: "); | |
// print the output from our function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<cs50.h> | |
int main (void) | |
{ | |
//To Do: Write a function to prompt the user for numberA and numberB | |
//To Do: Write a function to return the product of numberA and numberB. "The product of the number is: " | |
//After you are able to write the function and compile the program, make a header file and move the function protopye and definition here | |
//Add the include statement at the top of the file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
#include <math.h> | |
#define BASE 2 | |
// returns true if binary, false if not binary | |
bool check_binary(int b) | |
{ | |
while (b > 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cs50.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
// get a string named plaintext | |
string plaintext = get_string("plaintext: "); | |
// output the string |
NewerOlder