CCPS 393 exam questions & answers 2024/2025
C - ANSWERSC
Explain the difference between %d and %4d placeholders when printing - ANSWERS%4d reserves 4 spaces and right aligns the text, e.g
4285
6
but %d would just be centered
write the commands to read a string from input and print ...
Explain the difference between %d and %4d placeholders when printing - ANSWERS%4d reserves 4
spaces and right aligns the text, e.g
4285
6
but %d would just be centered
write the commands to read a string from input and print it out. Assume a macro is define with max size
SZ - ANSWERSchar s[SZ];
printf("Enter a string with max size %d: ", SZ);
fgets(s, SZ, stdin);
s[strlen(s) - 1] = '\0';
printf("You entered: %s \n", s);
Write the "cookbook" steps to reading/writing from a file - ANSWERSdeclare file pointers:
FILE* in;
FILE* out;
initialize pointers:
in=fopen("filename", "r");
out=fopen("filename", "w");
actions:
,fscanf(in, "placeholder", &variable);
fprintf(out, "placeholder", variable);
close files:
fclose(in);
fclose(out);
write the general syntax for a switch statement - ANSWERSswitch (variable) {
case (cond1):
action1;
break;
case (cond2):
case (cond3):
action2;
break;
}
fill in the blanks:
void swap (int *a, int *b) {
int temp;
temp=____; // set to variable pointed to by a
____ = ____; // set variable pointed to by a to the one pointed to by b
____ = temp; // set the variable pointed to by b
}
int main() {
int a=5, b=7;
, swap( ____, ____); // a is now 7, b is now 5
return 0;
} - ANSWERS*a
*a = *b
*b
swap(&a, &b)
write out the general format for a makefile - ANSWERStargetfile : dependenciesfiles
action (gcc ...)
targetfile2 : dependeciesfiles2
action
... and so on
the executable show_face depends on object files show_face.o and face.o
show_face.o depends on the source file show_face.c
face.o depends on the source file face.c
write the makefile - ANSWERSshow_face : show_face.o face.o
gcc show_face.o face.o -o show_face
show_face.o : show_face.c
gcc -c show_face.c
face.o : face.c
gcc -c face.c
clean:
rm *.o
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Bensuda. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.49. You're not tied to anything after your purchase.