Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C the variable types that can hold an integer are: Select one: O int and long int O int o O short int and
In C the variable types that can hold an integer are: Select one: O int and long int O int o O short int and int O short int, int and long int O char, short int, int and long int The following code: int x; scanf("%d", &x); if (x == 0) printf("x is zero. "); Select one: : O a. Always prints the message no matter what the user enters. O b. Only prints the message when the user enters 0. O c. Prints the message some times because x is not initialised. d. Does not compile because the brackets are missing. If a variable called x is declared in main AND a variable called x is declared in myFunction then: Select one: O a. this will not compile as you can't have two variables with the same name even in different functions. O b. can be used in main and myFunction but are actually the same variable O c. will always contain the same values as each other. O d. The variables happen to have the same name but are totally separate from each other. Given the following prototype: int my Function (void); Select one: . can return an integer but doesn't have too. O b. the function must use "return xxx;" (where xxx is some integer) to return an integer. doesn't have to use the return keyword. d. must have return 0; at the end. can just have the return keyword on it's own at the end of the function. C. e. Given the following code what is printed on screen? int x = 3; int *p = &X; = printf("%p", p); Select one: O a. the address of x. x O b. a random number. a an error - need to use %d or % i. d. the address of p. O e. 3 O C. Given the definition struct Date { int day; int month; int year; }; write a line of C code that uses the malloc() function to allocate space for an array N elements long, each element of type struct Date. Don't forget to include code that handles an unsuccessful malloc() call. The minimum and maximum values an unsigned char variable can hold are: Select one: 'a' and 'z' O 0 and 255 o 'a' and '9' O -128 and 127 -255 and +255 What gets stored in z as a result of the following code: unsigned char x = 0x12; unsigned char y = 0x23; unsigned char z; z = X & Y; Select one: O a. true O b. 0 O c. false O d. Ox35 O e. Ox02 Of. 35 g. 1 What does the following code do? struct Date int day; int month; int year; }; a. - Select one: creates a structure called struct Date that contains three members - day, month and year. O b. creates a structure called struct Date. creates three variables called day, month and year. O d. creates a template (blueprint) of what the structure will look like if one is declared later in the code. O C. A floatin C is accurate to: Select one: o 12 decimal places O 6 decimal places Whatever number of decimal places specified e.g. %.8f is accurate to 8 places etc. 18 decimal places O depends on the machine you are running the code on At the end of the main function there is usually the line: return 0; The purpose of this line is: Select one: O To return a code to the operating system to inform it whether or not the program ran successfully. O To finish the program. O To return the answer of the program. To tell the user that the program successfully or not. In C what is the result of the following expression: 27 % 5 Select one: 0 5.4 O 4 O 2 05 O 4.5 Which one of the lines below is a valid function call? Select one: a. void myTestFunction(); O b. void myTestFunction(int x); int myTestFunction(3); O d. myTestFunction(3); O e. myTestFunction(int x); C. Call by Value refers to: Select one: O a. passing numbers to function instead of varibles O b. a function that returns a number (value). O c. a function that accepts numbers (values) as parameters and not void. O d. the way parameters are passed by making a copy of the number (value) being passed What is declared by the following code? int *x, yi Select one: O a. a pointer to an integer called x and an integer called y. O b. nothing as they are notinitialised. two integers called x and y. d. a pointer to an integer called x and a pointer to an integer called y. two pointers to integers called x and y. O C. e. What does the following code do? y = 3; = int x = 2, y int *p = &X, *q = = &yi = p = 0; Select one: O a. Puts 3 into p. 3 O b. Puts the address of y into p. Puts 2 into q. O d. Puts 2 into y. Puts 3 into x. 3 Of. Puts the address of x int q. O c. O. Assuming that struct Date has already been defined how would you place an 8 into the day member of the 3rd element of the following array? struct Date birthdays [10]; Select one: = O a. birthdays.day[2] = 8. O b. birthdays.day[3] = 8. O c. birthdays[3].day = 8; O d. birthdays[2].day = 8; Consider a string s, declared as char s[20]; The line of code below attempts to copy the string "Hello" into s. Explain why the following line of code will not compile or run. How would you re-write it to successfully perform the copy? s = "Hello
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started