Question

QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start...

QUESTION 1

What statement would you use to print the phrase “Hello, world” and then start a new line?

QUESTION 2

What statement would you use to assign the value 32 to the variable cheeses?

QUESTION 3

What statement would you use to read a value from keyboard input into the variable cheeses?

QUESTION 4

What statement would you use to print “We have X varieties of cheese,” where the current value of the cheeses variable replaces X?

QUESTION 5

Write a C program that displays your name and address (or if you value your privacy, a fictitious name and address).

QUESTION 6

Declare variables matching the following descriptions:

A short integer with the value 80

An unsigned int integer with the value 42,110

An integer with the value 3,000,000,000

  

QUESTION 7

Evaluate the following expressions as C++ would:

8 * 9 + 2

6 * 3 / 4

3 / 4 * 6

6.0 * 3 / 4

15 % 4

QUESTION 8

What is the variable type for each of the following declarations?

auto cars = 15;

auto iou = 150.37f;

auto level = 'B';

auto crat = U'/U00002155';

auto fract = 8.25f/2.5;

QUESTION 9

Construct logical expressions to represent the following conditions:

weight is greater than or equal to 115 but less than 125.

ch is q or Q.

x is even but is not 26.

x is even but is not a multiple of 26.

donation is in the range 1,000–2,000 or guest is 1.

-- Font family -- -- Font size --
-- Format --HeadingSub Heading 1Sub Heading 2ParagraphFormatted Code -- Font family --Andale MonoArialArial BlackBook AntiquaComic Sans MSCourier NewGeorgiaHelveticaImpactSymbolTahomaTerminalTimes New RomanTrebuchet MSVerdanaWebdingsWingdings

QUESTION 10

Convert the following to a do/while loop. It should produce exactly the same output.

#include

int main(){

int i=0, k=0;

float j=0;

int counter = 10;

printf("Begin counting");

for (i=0; i < counter; i++) {

printf(i);

}

return 0;

}

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

Note : I have implemented the all the questions in C programming language.

Question 1:

To print the phrase Hello World we use

printf("Hello World \n");

Here the "/n " will direct you the new line after printing the required statement.

Question 2:

Here first we declare the variable cheeses, as it is taking the integer values we will assign it as int.

int cheese =32; //declaring the variables and assigning it value 32.

Question 3:

As we have declared variables as integer(int) so we take input from the keyborad as follows:

printf("Enter the value of the Cheese");

scanf("%d", &cheese); // this will allow the user to input the value to the variable cheese.

Question 4 :

Let us assume that we have one more variable 'X'. now the code will look like this below:

int x=0; //initially we have provided zero as the intial value

x=cheese; //this will assign the value of varialble cheese to variable X.

printf(" We have %d varieties of cheese",x); // this will print the required output

Question 5:

To display the name and the address we need to take the 2 variables of string type.the program is as follows:

int main ()

{

char name[20]; //defined the variabla name

char address[20]; //defined the variable address

printf("enter the name ");

scanf("%s",name); //taking name from the keyborad

printf("enter the address");

scanf("%s",address); //taking address from keyborad

Now after getting the input we print the name and address in final.

printf( "the name is %s /n and the address is %s",name,address); //here the name and the address will be printed in the different line for improved readability.

return 0;

}

Question 6:

The variable declaration is as follows:

short a=80; //Here we have assumed variable 'a'.

unsigned int a=42110; //Comma are not allowed in the assignment.

Hence the compiler of C language are machine dependent, therefore some of them take 2 bytes of memory and some of them take 4 bytes of memory.

So such big value cannot be assigned of system which uses 2 bytes of memory. Therefore in system which takes 4 bytes of memory we will declare variable as

unsigned int a=3000000000;

Question 7:

The statement are as below:

printf("%d",(8*9)+2);

printf("%d",(6*3)/4);

printf("%d",(3/4)*6);

printf("%d",(6.0*3)/4);

printf("%d",15%4);

The value evaluated above are totally based on the associativity of the operator. Here there is confusion sometimes that which operation to be performed first,hence one should know the associativity of the operators in C.

Question 8:

The variable type is given as follows for each of the expression:

int //beacuse the varibale is being assigned the integer value.

float //the postfix 'f' after the variable represents the float variable type.

char // the character variable are always in the single quotes.

char // the single quote represents the variable of character type.

float // the float variable is being divided by float variable and hence comes out to be float value.

Question 9:

The logical expression of the statements are as follows:

(weight>=115 && weight<125 ) //Here we assume weight as the integer variable.

(ch== 'q' || ch== "Q' ) //Here we assume ch is character variable.

(x%2==0 && x!=26) //Here % operator will check for the even number.

((x%2)==0 && (x%26)!=0) //Check for the even and the divisibility too.

((donation>=1000 && donation<=2000) || guest ==1) //We assume that guest and donation are the variables.

Question 10.

The modified code is as below:

#include<stdio.h>

int main()

{

int i=0, k=0;

float j=0;

int counter = 10;

printf("Begin counting");

do{ //It will keep on looping and printing till while condition evaluates to flase.

printf(i);

}while(counter!=0);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start...
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
  • Use the following Information to answer questions for a hypothetical population. Figure 2 Ages (years) Population...

    Use the following Information to answer questions for a hypothetical population. Figure 2 Ages (years) Population # Deaths POPULATION A 15-19 1,000 30 20-24 4,000 16 25-29 6,000 121 Total 11,000 167 POPULATION B 15-19 5,000 120 20-24 2,000 20 25-29 500 20 Total 7,500 160 Using Figure 2, calculate the crude mortality rate ratio of Population A compared to Population B. -- Font family -- -- Font size -- -- Format --HeadingSub Heading 1Sub Heading 2ParagraphFormatted Code -- Font...

  • QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start...

    QUESTION 1 What statement would you use to print the phrase “Hello, world” and then start a new line? Path: pWords:0 10 points Save Answer QUESTION 2 What statement would you use to assign the value 32 to the variable cheeses? Path: pWords:0 10 points Save Answer QUESTION 3 What statement would you use to read a value from keyboard input into the variable cheeses? Path: pWords:0 10 points Save Answer QUESTION 4 What statement would you use to print...

  • QUESTION 14 A company purchases supplies on account, what is the effect on the accounting equation?...

    QUESTION 14 A company purchases supplies on account, what is the effect on the accounting equation?    Assets decrease; equity increases Assets decrease; equity decreases Liabilities decrease; equity decreases Liabilities increase; equity increases Liabilities increase; assets increase 4 points    QUESTION 15 Unearned revenues are: Revenues that have been earned and received in cash Revenues that have been earned but not yet collected in cash Liabilities created when a customer pays in advance for products or services before the revenue...

  • An 8-month old male patient is admitted to the pediatric unit with a general diagnosis of failure to thrive. The paren...

    An 8-month old male patient is admitted to the pediatric unit with a general diagnosis of failure to thrive. The parents have observed a slowness in the development of motor skills. They also mention the occasional appearance of a substance resembling orange sand in the child's diapers. Urinalysis results are: color- yellow protein- negative blood: negative appearance: slightly hazy Glucose: normal Urobilinogen- normal Sp. gravity: 1.024 Ketones negative Nitrite- negative pH: 5.0 bilirubin:- negative Leukocytes- negative Microscopic: Many uric acid...

  • QUESTION 1 In order to print the members of structures in the array, what will be...

    QUESTION 1 In order to print the members of structures in the array, what will be the contents of blanks in the printf statement of the code snippet given below? #include <stdio.h> struct virus {    char signature[25];       char status[20]; } v[2] = {                               "Yankee Doodle", "Deadly",                               "Dark Avenger", "Killer"                   } ; void main( ) {       for (int i = 0; i < 2; i++)                   printf( "\n%s %s", _______________ , _____________ ); } A. signature, status B. v.signature,...

  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • Please note that Questions 15 to 17 are connected questions. Question 15: The following shows a...

    Please note that Questions 15 to 17 are connected questions. Question 15: The following shows a partial DNA sequence from the wild-type (normal) allele for the human leukemia-linked apoptotic gene.   5' ATGCGATTAATCGGTAAA 3' (non-template strand) 3' TACGCTAATTAGCCATTT 5' (template strand) Please answer the following questions: (a) If the bottom strand serves as the DNA template for transcription, what is the resulting mRNA sequence? The mRNA sequence is  5'  3'. (2 marks) 5' AUG CGA UUA AUC GGU AAA 3' ? Please enter...

  • Question- How would I allow the program to run both upper and lower case letters. How...

    Question- How would I allow the program to run both upper and lower case letters. How would I write a switch statement for upper and lower cases to see if the value entered for Grade2 is a A or a? C programming int main() { char Grade2; float gradepoint; char Grade = 'X'; // Declares a character type variable named Grade printf("Enter a grade\t"); // Prompts for Grade scanf("%c", &Grade); // Inputs Grade printf("Grade is: \t%c\n", Grade); // Prints the...

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • Please answer and explain thank you. Question 1 What will be printed when the following code...

    Please answer and explain thank you. Question 1 What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); Group of answer choices 45678.259 0,045,678.26 45,678.26 45,678.3 Question 2 What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); Group of answer choices 45678.259 45,678.259 45,678.26 45,678.3 Question 3 What will be the value of ans after the following code has been executed? int ans=0;...

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