This file contains hidden or 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
bool isValidPassword(char* passwordCandidate){ | |
// Requirements: Assume false until proven valid | |
bool hasUpper = false; | |
bool hasLower = false; | |
// Assess password candidate | |
size_t n = strlen(passwordCandidate); | |
for(int i = 0; i < n; i++){ | |
char x = passwordCandidate[i]; | |
if(isupper(x)){ hasUpper = true; } |
This file contains hidden or 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 <stdlib.h> | |
// Define an enum for traffic light colors | |
#define NUM_LIGHT_STATES 3 | |
typedef enum { RED = 0, YELLOW, GREEN } Light; | |
This file contains hidden or 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> | |
// Excercise 1: Pointer Notation | |
// Use only pointer arithmetic | |
// and refrain from using index notation e.g, arr[0]. | |
// Print out the non-zero values of arr. | |
// Do not use any control flow (loops, while, etc...). | |
// Output: 1234 | |
int main(int argc, char* argv[]) | |
{ |
This file contains hidden or 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 "queue.h" | |
// Initialize the queue with a specified capacity | |
bool queue_init(queue_t *queue, int capacity) { | |
assert(queue != NULL); // Ensure the queue pointer is valid | |
assert(capacity > 0); // Ensure the capacity is a valid positive number | |
// Setting members | |
queue->items = (int *) malloc(capacity * sizeof(int)); // Allocate memory on the heap |
This file contains hidden or 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
#ifndef QUEUE_H | |
#define QUEUE_H | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <assert.h> | |
// Static queue structure | |
typedef struct { |
This file contains hidden or 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 <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
// use typedef person struct | |
typedef struct Person { | |
char name[50]; | |
int age; | |
float weight; |
This file contains hidden or 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
/** | |
* INTEGER CSV READ OPERATION | |
* COMPUTES SUM per LINE in CSV | |
*/ | |
// Libraries | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
This file contains hidden or 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 <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <ctype.h> | |
#include <string.h> | |
// Precondition: | |
// Accept a string | |
// Accept spaces | |
// Capital and lowercase letters |
This file contains hidden or 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 "stack.h" | |
int main(void) { | |
// Your code here | |
printf("Hello, Stacks!\n"); | |
Stack* s = stackCreate(INIT_STACK_CAPACITY); | |
stackPush(s, 10); | |
stackPush(s, 20); | |
stackPush(s, 30); |
This file contains hidden or 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
problem: Bit Storage Problem 3 | |
suites: | |
- name: Asserts & Error Handling | |
pts: 10 | |
tests: | |
- command: | |
- ./mysolution | |
- ../data/schedules5.txt | |
name: File Exists | |
solution: Program did not return a value |
NewerOlder