Professional Documents
Culture Documents
Homework 1 Cse31
Homework 1 Cse31
Cse31
Problem 1
a)
Binary Unsigned Signed 1’s 2’s Biased
Complement Complement
1100 1010 202 -54 110101 110110
b)
Property Unsigned Signed 1’s Comp 2’s Comp Biased
Problem 3
a) char* changeCase(char* str){
char* p;
char* result;
result = (char*) malloc((strlen(str)+1)*sizeof(char));
strcpy(result, str);
*n = changeCase(*n);
changeCase_by_ref( &(name[i]) );
Problem 4
typedef struct {
char name[MAX_NAME_LEN];
unsigned long sid;
} Student;
strcpy(s->name, name);
}
/* return the SID of student s */
unsigned long getStudentID(const Student* s) {
/* fill me in */
return s->sid;
}
/* fill me in */
s->studentID= studentID;
}
b)
// Here in the above code we can't return a pointer to a locally declared variable Student. It will
return a null value as the variable is going to be a garbage value.
// SO Instead, you need to allocate a student first can solve the logical error.
}
//And then let the calling application allocate the student.