Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions assignment6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Emma Ladouceur


1. This code will print

203 1 23

because the specific emp1 overrides the initial values set for the employee struct.


2. enumerations are simply words used for numbers. So for an enumeration of months those words really just stand for numbers 0-11, but a struct can have many values. Each thing doesn't stand for a number and you can get the value of the stuct to print or return not just it's numbered position.


3. I'm not really sure but I think that to pass an array into a function you might have to go through a loop to print each value, or you need to look for a specific space in that array, but for a structure it depends of if you're looking for all of the values of the structure or just the array in which case you can loop through for just that piece of the structure.
Binary file added bank
Binary file not shown.
61 changes: 61 additions & 0 deletions banking.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//Emma Ladouceur
//Assignment 6 banking.c
//This compiles, but I'm still having some trouble with the values I put in for the balance... can't figure that out.

#include <stdio.h>

typedef struct bank {

int accNum;
char name[100];
float balance;

} bank;


float withdraw(bank b, float a){

float newbalance;
b.balance= b.balance-a;
printf("Your new balance is %f", b.balance);
}

float deposit(float a, bank b){

float newbalance;
b.balance= b.balance + a;
printf("Your new balance is %f", b.balance);


}

int main(){
char name;
printf("What is your name");
scanf("%s", &name);
printf("Would you like to deposit(type 1) or withdraw (type 2)\n");
bank bank1 = {1, name, 600.0};
bank bank2 = {2, name, 500.0};

int response;
scanf("%d", &response);
if(response == 1){
float depo;

printf("How much are you depositing");
scanf("%f", &depo);
deposit(depo, bank1);

}

if(response ==2){
float with;

printf("How much are you withdraw");
scanf("%f",&with);
withdraw(bank1,with);

}

printf("%f",bank1.balance);
}
Binary file added complex
Binary file not shown.
74 changes: 74 additions & 0 deletions complex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//Emma Ladouceur

//Hmmmm, this seems like the best way to do it, but i didn't use stuct. I'm not sure even how you would, but maybe that's better for the mult and div which I couldn't get to work.

#include <stdio.h>
int add(int a, int b, int c, int d){
int sum1, sum2;


sum1 = a+c;
sum2 = b+d;

printf("The sum is %d + %di\n", sum1, sum2);


}
int sub(int a, int b, int c, int d){
int sum1, sum2;

sum1=a-c;
sum2 =b-d;

printf("The difference is %d + %di\n", sum1, sum2);

}

int mult(int a, int b, int c, int d){

}

int div(int a, int b, int c, int d){

}

int main(){

int choice;
int a, b,c,d;

printf("What operation with complex numbers would you like to perform? \n 1 for addition\n 2 for subtraction \n 3 for multiplication \n 4 for division.\n");

scanf("%d", &choice);

if(choice ==1){
printf("Enter a number a and b where b is bi\n");

scanf("%d",&a);
scanf("%d",&b);

printf("Enter a number c and d where d is di\n");
scanf("%d",&c);
scanf("%d",&d);
add(a,b,c,d);
}

if(choice ==2){
printf("Enter a number a and b where b is bi\n");
scanf(" %d",&a);
scanf(" %d",&b);

printf("Enter a number c and d where d is di\n");
scanf(" %d",&c);
scanf(" %d",&d);
sub(a,b,c,d);
}

// if(choice == 3)

// if(choice == 4)




}
Binary file added students
Binary file not shown.
66 changes: 66 additions & 0 deletions students.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <stdio.h>

typedef struct student {

char name[100];
int age;
int scores[5];
int average;
int sum,i;

} student;




int main(){



student s1= {"Emma", 17, {60,99,100,40,30}};


student s2= {"Katherine", 16, {88,99,47,89,100}};
student s3={"Aly", 17, {100, 99, 90, 54, 70}};

//int grades[] = {10, 10, 12, 29, 10};
student s4={"George", 4, {100,99,99,89,88}};
student s5={"Dean", 1, {33,78,55,66,33}};


student s[] = {s1,s2,s3,s4,s5};
int i, j;
int sum=0;
for(i=0;i<5;i++){
sum = 0;
for(j=0; j<5;j++){
sum = sum + s[i].scores[j];

}
s[i].average = sum/5;

}



//Student 1
printf("Name: %s\n", s[0].name);
printf("GPA: %d\n", s[0].average);
printf("Age: %d\n", s[0].age);
//Student 2
printf("Name: %s\n", s[1].name);
printf("Age: %d\n", s[1].age);
printf("GPA: %d\n", s[1].average);
//Student 3
printf("Name: %s\n", s[2].name);
printf("GPA: %d\n", s[2].average);
printf("Age: %d\n", s[2].age);
//Student 4
printf("Name: %s\n", s[3].name);
printf("GPA: %d\n", s[3].average);
printf("Age: %d\n", s[3].age);
//Student 5
printf("Name: %s\n", s[4].name);
printf("GPA: %d\n", s[4].average);
printf("Age: %d\n", s[4].age);
}