Question

In: Computer Science

QUESTION 1 The statement char ch = ‘A’ would store in ch A. The character A...

QUESTION 1

  1. The statement char ch = ‘A’ would store in ch

    A.

    The character A

    B.

    ASCII value of A

    C.

    A along with the single inverted commas

    D.

    Both (a) and (b)

2 points   

QUESTION 2

  1. Which of the following scanf() statement will you use to accept following variables?

    float gravity_a;

    double gravity_b;

    A.

    scanf("%f %lf", &gravity_a, &gravity_b);

    B.

    scanf("%LF %f ", gravity_a, gravity_b);

    C.

    scanf("%LF %LF ", &gravity_a, &gravity_b);

    D.

    scanf("%f %LF ", gravity_a, gravity_b);

2 points (Extra Credit)   

QUESTION 3

  1. What will be the output of the following program?

    #include<stdio.h>
    int main()
    {
        float a=6.15528;
        printf("%2.1f\n", a);
        return 0;
    }
    A.

    6.00

    B.

    6.15

    C.

    6.2

    D.

    6

2 points (Extra Credit)   

QUESTION 4

  1. What will be the output of the following statements?

    const int count = 10;
    count++;
    printf("%d", count);
    A.

    10

    B.

    11

    C.

    Run-time Error

    D.

    Compile-time Error

3 points   

QUESTION 5

  1. What will be the output of the following program?

    #include<stdio.h>

    int main()

    {

          int a = 5, b = 2;

          printf("%d ", a+++b);

          printf("%d %d", a, b);

          return 0;

    }

    A.

    Results in Syntax Error

    B.

    Prints 7 6 2

    C.

    Prints 8 6 2

    D.

    None of the above

Solutions

Expert Solution

QUESTION 1

The statement char ch = ‘A’ would store in ch

A.

The character A

The option A suits well, Char data type will store the character value in it, So ch will hold the Character A.

QUESTION 2

  1. Which of the following scanf() statement will you use to accept following variables?

    float gravity_a;

    double gravity_b;

    A.

    scanf("%f %lf", &gravity_a, &gravity_b);

The option A suits well,

As the format for scanf to get the value of float is %f and the format for scanf to get the value double is %lf. so the correct format to get the input is A option.

QUESTION 3

  1. What will be the output of the following program?

    #include<stdio.h>
    int main()
    {
        float a=6.15528;
        printf("%2.1f\n", a);
        return 0;
    }
    C.

    6.2

The option C suits well

The formatting of %2.1f will represent 2 digits before decimal point and one digit after decimal point in float data type.

Thus the option is C.

QUESTION 4

  1. What will be the output of the following statements?

    const int count = 10;
    count++;
    printf("%d", count);
D. Compile-time Error

The option D will be suitable.

count is declare as const - constant variable

As we can increment a constant variable, incrementing count will lead to compile time error of incrementing a read-only variable.

QUESTION 5

  1. What will be the output of the following program?

    #include<stdio.h>

    int main()

    {

          int a = 5, b = 2;

          printf("%d ", a+++b);

          printf("%d %d", a, b);

          return 0;

    }

B. Prints 7 6 2

The option B suits well,

As per the increment operator precedence a+++b will be executed as (a++) + (b) thus a will be incremented to 6.


Related Solutions

C Implement the function Append (char** s1, char** s2) that appends the second character array to...
C Implement the function Append (char** s1, char** s2) that appends the second character array to the first, replaces the first array with the result and replaces the second character array with the original first array. For example, if the first character array is "hello" and the second is "world" at the end of the function the new value of the first character array should be"helloworld" and the second array should be "hello". If the input is invalid the function...
Find the output for the following statements. System.out.println(3%2+1+(3/2)); char ch = 69; System.out.println(ch); int x =...
Find the output for the following statements. System.out.println(3%2+1+(3/2)); char ch = 69; System.out.println(ch); int x = 30; int y = 4; double z = x/y; System.out.println(z);
Translate the following C program to Pep/9 assembly language: #include <stdio.h> char toLower(char ch) { if...
Translate the following C program to Pep/9 assembly language: #include <stdio.h> char toLower(char ch) { if (ch >= 'A' && ch <= 'Z' )        ch += 'a' - 'A'; return ch; } int main() { char ch, conversion; printf("Enter an uppercase letter: "); scanf("%c", &ch); conversion = toLower(ch); printf("\nLetter after conversion: %c\n\n", conversion); return 0; }
. Consider the character array as follows: char mySentence[] = "Hello World!"; The number of characters...
. Consider the character array as follows: char mySentence[] = "Hello World!"; The number of characters in the array can be determined by application of the strlen() function. Therefore, the end of the array can be determined by pointer arithmetic as follows: char * endArray = mySentence + strlen(mySentence); Now that the end of the array has been determined, utilise pointers in C++ to output each character in array in reverse and display it to the console window. What other...
in C programming language char character [100] = "hello"; a string array variable It is given....
in C programming language char character [100] = "hello"; a string array variable It is given. By writing a function called TranslateString, By accessing the pointer address of this given string, returning the string's address (pointer address) by reversing the string Write the function and use it on the main function. Function void will not be written as. Return value pointer address it will be. Sweat operation on the same variable (character) It will be made. Declaration of the function...
Determining character type without using char methods. (epic confusion) 1. Call your class Program4A, so your...
Determining character type without using char methods. (epic confusion) 1. Call your class Program4A, so your filename will be Program4A.java. It is essential for grading purposes that everyone have the same class name. 5. Ask the user for a single character "Please enter a single character, followed by the enter/return key. 6. Read in the character and assign it to a variable of char. 7. compile and run program. Don't move on until this part is working. I have entered...
Implement the following function: a. float temp(float t, char ch) – this function takes temperature ‘t’...
Implement the following function: a. float temp(float t, char ch) – this function takes temperature ‘t’ and unit of temperature ‘ch’ as parameter. The variable ‘ch’ will be either f or c depending on whether the temperature in variable ‘t’ is in Fahrenheit or Celsius. The function returns the converted temperature to the main method. Call the above function in the main method. Initialize temperature and unit of temperature from the user and pass them as parameter to the above...
Which of the following would you find on the Statement of Equity? Question 22 options: 1)...
Which of the following would you find on the Statement of Equity? Question 22 options: 1) Capital stock 2) Income tax expense 3) Gain on sale of building 4) Dividends paid 5) Retained earnings 6) Sales 7) Salary expense 8) Cash 9) Net income 10) Loss on sale of investment
Question 1   Which of the following would be a “red flag” of potential financial statement fraud...
Question 1   Which of the following would be a “red flag” of potential financial statement fraud for a nonpublic company that would need further investigation? a The Company issued annual GAAP financial statements on February 28th, even though its books were closed on January 15th. b The GAAP financial statements were “reviewed” by a CPA in accordance with AICPA standards, but the Company has never undergone a financial statement audit in accordance with GAAS. c The Company has changed auditors...
CASE – 1: (Based on Ch-1: Investing Setting) – Soon after your graduation, you would be...
CASE – 1: (Based on Ch-1: Investing Setting) – Soon after your graduation, you would be all set for your career path. As you have studied and learnt several investment and portfolio related theories and concepts, you would be interested to start investing and creating portfolio right from the beginning phase of your career. Before you start doing so, it would be ideal to recap those important concepts and theories. You may want to write down those in brief especially...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT