Question

31. True or False: The condition in the following if statement is a syntax error:

 31. True or False: The condition in the following if statement is a syntax error:

 int number=50;

……

 if (number)

……

 32. True or False: The standard C functlon strlen) will return 4 when invoked upon the varlable

 name, declared below:

 char namel = (e', 'p', 't', 's', '\0', '1', '2', '1', '\0'];

 33. True or False: A structure is a collection of related variables under one name.

 34. True or False: In C, output parameters allow for a function to return more than one value Indirectly.

 35. True or False: A variable of a specific struct type can be copied to another variable of the same struct type through strcpy ().

 36. True or False: An array of structs may be used to replace parallel arrays, if the appropriate attributes are defined in the struct.

 37. True or False: Function malloc () is used to dynamically allocate memory at program runtime 38. True or False: Shifting a number right by two-bit positions, using >>, is the same as multiplying the number by four.

 39. True or False: Character arrays that are passed to functions in the C character library (ctype.h)

 need to always have a null character as the last terminating element in order to achieve the correct result.

 40. True or False: An iterative construct (i.e. a while, for, do-while loop) may always be used Instead of recursion.

 41. True or False: The bitwise AND (&) operator may be used to clear individual bits.

 42. True or False: More bytes of memory are required for a double precision variable than a character variable.

 43. True or False: Given the following snipet of code:

 char tmy ptr= "CotS 121";

 printf ("%e", A(my ptr++));

 The output of the printf is 'p'.

 44. True or False: The functions in <string.h> use the length of the string to determine the end of the string.

 5. True or False: The strcmp function in <string h> will return 0 when comparing "CptS121" to "cpts121".

3 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

Question 31. The condition in the following if statement is a syntax error:

int number = -50;
...
if(number)
...

Answer:
False

Explanation:
in C if a number is given as condition to a if statement if it is 0 then it is evaluated to false else it is true.So the statement has no syntax errors.

Question 32. The standard C function strlen() will return 4 when invoked upton the variable name ,declared below:
       char name[]={'c','p','t','s','\0','1','2','1','\0'};

Question 32. The standard C function strlen() will return 4 when invoked upton the variable name ,declared below:
       char name[]={'c','p','t','s','\0','1','2','1','\0'};

Answer:
True

Explanation:
The function strlen calculates the number of characters untill the first occurence of '\0'. Here the number of characters before '\0' is 4.

Question 33. A structure is a collection of related variables under one name.

Answer:
True

Explanation:
Structure is a user defined datatype to combine data of different types together.So it can be a collection of related variables under a common name.

Question 34. In C,output parameters allow for a function to return more than one value indirectly.

Answer:
False

Explanation:
No matter a function can return only a single return value.
Even if a array is returned it is considered as a single variable.

Question 35. A variable of a specific struct type can be copied to another variable of the same struct type through strcpy

Answer:
False

Explanation:
We can copy a string to structure if it has a string variable inside it using strcpy().But not for all types of variables

Question 36. An array of structs can be used to replace parallel arrays,if the appropriate attributes are defined in the struct.

Answer:
True

Explanation:
The struct array can be used to replace parallel arrays .We can acces the variables of struct array using indices

Question 37. Function malloc() is used to dynamically allocate memory at program at runtime.


Answer:
True

Explanation:
To allocate memory at runtime is the function of malloc

Question 38. Shifting a number right by two bit positions using >>, is the same as multiplying the number by four.

Answer:
True

Explanation:
Shifting a number right by 1 means multiplying the number by 2.
So Shifting a number right by 2 means multiplying the number by 4.

Question 39. Character arrays that are passed to fuctions in the C character library (ctype.h) need to always have a null character as the last terminating element in order to acheive the correct result

Answer:
False

Explanation:

The compiler will automatically add a '\0' to the C string.
So It is not necessary to have a null character always.

Question 40. An iterative construct (ie a while ,for ,do-while loop) may always be used instead of recursion.

Answer:
True

Question 41. The bistwise AND (&) operator may be used to clear individual bits.

Answer:
True

Explanation:
The bitwise AND may be used to clear selected bits (or flags) of a register in which each bit represents an individual Boolean state.

Question 42. More bytes of memory are required for a double precision variable than a character variable

Answer:
True

Explanation:
char data type variable requirews only 1 byte whereas
double data type requires 8 bytes.

Question 43. Given the following snipet of code.
   char *my_ptr="Cpt$ 121";
   printf("%c",*(my_ptr++));

Answer:
False

Explanation:
the character at *(my_ptr++) wil be printed .
*my_ptr points to 0 th index of the array.
Only after printing the character the pointer will be incremented.
So the value printed will be "C".

Question 44. The functions in use the length of the string to determine the end of the string


Answer:
False

Explanation:
The functions in uses '\0' to mark the end of he string.
If there is no '\0' it will add it to the string.

Question 44. The strcmp() function in will return 0 when comparing "CptS121" to "cpts121"

Answer:
False

Explanation:
Both are different values .
So the result will not be 0.

Add a comment
Know the answer?
Add Answer to:
31. True or False: The condition in the following if statement is a syntax error:
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • True or False: Algorithms should be specified in pseudocode before they are implemented in C

     17.True or False: Algorithms should be specified in pseudocode before they are implemented in C.  18. True or False: In C, false is defined as any result that is zero. 19. True or False: An advantage to defining functions in C is that they may be reused in other projects. 20. True or False: Suppose a function main calls a function f. As a parameter to f, main passes a pointer p to a struct. Further suppose that f's body modifies p by...

  • State whether each of the following is true or false. If false, explain why: a.Referring to...

    State whether each of the following is true or false. If false, explain why: a.Referring to an array element outside the array bounds is a syntax error. b.When initializing an array at its declaration, it is a syntax error to provide less initializers than the number of array elements. c.A character array can be initialized using a string literal. d.An individual array element that is passed to a function and modified in that function will contain the modified value when...

  • IN C ONLY As mentioned earlier there are two changes we are going to make from...

    IN C ONLY As mentioned earlier there are two changes we are going to make from lab 5, The file you read into data structures can be any length. studentInfo array will be stored in another struct called studentList that will contain the Student pointer and current length of the list. Sometimes data can be used in structs that correlate between variables so it's convenient to store the data in the same struct. Instead of tracking a length variable all...

  • ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE...

    ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...

  • Question 11 pts Fill in the blank. Two functions are defined main.c and MyAge.c   // FILE...

    Question 11 pts Fill in the blank. Two functions are defined main.c and MyAge.c   // FILE main.c main ( ) { _______ int age ; printf ( " the value of age is %d \n", age ) ; } // FILE MyAge.c int age = 10; int MyAge ( ) { } Group of answer choices static external internal extern Flag this Question Question 21 pts Fill in the blank. Two functions are defined main.c and MyAge.c   The below program...

  • T/F C Language Questions. Answer the following true/false questions. You must correctly state WHY your answer...

    T/F C Language Questions. Answer the following true/false questions. You must correctly state WHY your answer is true or false in order to receive credit. #include <stdio.h> #include <string.h> int run_through(int num, char **a) { int i; int check=0; for(i=0;i<num;i++) { printf("%s\n", *(a+i)); if(strcmp(*(a+i), "filename")==0) { check=1; } } return check; } char** find_filename(int n, char **b) { int i; int check=0; for(i=0;i<n;i++) { if(strcmp(*b, "filename")==0) { b++; break; } b++; } return b; } int main(int argc, char **argv)...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

  • Question 8 A C-string is a sequence of characters terminated by the null character. True False...

    Question 8 A C-string is a sequence of characters terminated by the null character. True False D Question 9 What is the longest C-string that can be put into this C-string variable? char s[9]; There is not enough information to determine the 8th Question 10 D AC string variable is just an array of characters without the null character. True False Question 11 5 pts If you have already removed a character in char variable ch) from the input stream,...

  • Malloc function For the prelab assignment and the lab next week use malloc function to allocate...

    Malloc function For the prelab assignment and the lab next week use malloc function to allocate space (to store the string) instead of creating fixed size character array. malloc function allows user to allocate memory (instead of compiler doing it by default) and this gives more control to the user and efficient allocation of the memory space. Example int *ptr ptr=malloc(sizeof(int)*10); In the example above integer pointer ptr is allocated a space of 10 blocks this is same as creating...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT