100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
SER 334 || with Complete Solutions. $11.49   Add to cart

Exam (elaborations)

SER 334 || with Complete Solutions.

 3 views  0 purchase
  • Course
  • SER 334
  • Institution
  • SER 334

2*6*4 bytes correct answers int multi_array[2][6] = {{10000, 2, 3, 9, 10, 10}, {7, 8, 9, 9, 1999, 0}}; int size = sizeof(multi_array); What is the value of size? ptr is an integer pointer that is equal to the value at address j. correct answers Int* ptr = &j; Int x is created P is a pointe...

[Show more]

Preview 2 out of 13  pages

  • August 2, 2024
  • 13
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • SER 334
  • SER 334
avatar-seller
FullyFocus
SER 334 || with Complete Solutions.
2*6*4 bytes correct answers int multi_array[2][6] = {{10000, 2, 3, 9, 10, 10}, {7, 8, 9, 9, 1999, 0}};
int size = sizeof(multi_array);
What is the value of size?
ptr is an integer pointer that is equal to the value at address j. correct answers Int* ptr = &j;
Int x is created
P is a pointer to the address of x
X is set to 100
P is set to the address value minus 1
Print value of x which was changed by P which is 99. correct answers int x, *p = &x;
x = 100;
*p = *p - 1;
printf("The value of x is %d.\n", x);
Int x is established, int p is the address of x
X is set to 100
Error here since p is not a variable and not a pointer so *p must be be used. correct answers int x,
*p = &x;
x = 100;
p = p * 2;
printf("The value of x is %d.\n", x);
p = ma;
p = &ma[0][0];
p = &ma;
p = ma[0];
p = *ma; correct answers Assume you have declared a multi-dimensional array char ma[5][30]. What is the address of the element "ma[0][0]"?
Move declaration before main() correct answers #include <stdio.h> void main() { somefunc(10);
} void somefunc(int n) { //prints integers from n to 1. if (n > 0) { printf("%d", n); somefunc(n - 1); } }
This program does not compile. What is the issue and how can it be fixed?
It's trying to set the first eight bits in the binary representation of j to zero. correct answers int* ptr = &j;
*((char*)ptr) = 0;
What is this code trying to do to the value stored in j? (Hint: think in terms of bits.)
void toupper(char* str) { while(*str){ if (*str>96 && *str<123){ *str=*str-32; *str++; } else if (*str==32){ *str++; } else{ *str++; } }
} correct answers #include <stdio.h>
void toupper(char* str) { //WRITE THIS CODE
}
void main() { char text[] = "Some sample text"; toupper(text); printf("%s", text);//prints "SOME SAMPLE TEXT"
}
In Java, arrays are objects and other data can be associated with them. Like the number of elements. In C, arrays are just addresses and don't have any meta-data associated with them. Hence, we have to use a termination character to provide a way to tell how long a string is (i.e. a known stopping point). Else, we only have a starting place and could end up visiting all the memory after it. correct answers Why do we need to use null characters to denote the end of a string? No string termination character is used in Java.
An array is a pointer because it needs to indicate the location of the starting element, and the memory addresses of all the proceeding values stored in the data structure. The values are stored together in a linear fashion, so the memory addresses aren't scattered around, and thus our access and manipulation of values can be quick and efficient. What makes it a pointer is that it holds the
address of the first element, as mentioned above. Thus, to access elements following elements, we would do the following: say we wanted to access the third element of an array we would use

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

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

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

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 FullyFocus. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $11.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78998 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.49
  • (0)
  Add to cart