Question

Assume you have the following variable declarations and assignments: int j2: int k3; char ch float x2.3 Write single printf

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main(){
   int j = 2;
   int k = 3;
   char c = 'h';
   float x = -2.3;
   
   printf("The value of j is %d, and the value of x is %.2f, and the character c contains the value %c.",j,x,c);
    return 0;
}

The value of j is 2, and the value of x is -2.30, and the character c contains the value h.

Add a comment
Know the answer?
Add Answer to:
Assume you have the following variable declarations and assignments: int j2: int k3; char c'h float...
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
  • Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You...

    Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...

  • 9. Which of the following is true for the following program? #include <stdio.h> int maino int...

    9. Which of the following is true for the following program? #include <stdio.h> int maino int i = 1; switch (0) case 1: printf("%d", 0); case 2: printf("%d", 0); case 3: printf("%d", 0); default: printf("%d", 1); return 0; } (2 points) The program has no error, the output is 1111 The program has no error, the output is 1 The program produces a compile time error, because there are no break statements The program produces a compile time error, because...

  • 1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf...

    1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...

  • Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays...

    Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays their values: 1. Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the character with a %d format. 2. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your...

  • Program 2: Thread version int i = 100; char *buffer: void *tfuc(void *noarg) { int j...

    Program 2: Thread version int i = 100; char *buffer: void *tfuc(void *noarg) { int j = 0; printf("B:1-%d, j = %d\n",1,1); printf("B: I = %d, j = %d\n",1,1); j = 3; strcpy(buffer, "red"); Pthread exit(NULL); //print the string (show values of i, j) //print the string (show values of i,1) //copy the string "red" to buffer. int main(void) { pthread_t tid; //declaring vars int j = 1; buffer strcpy(malloc(100), "blue"); //Initialize buffer and copy the "blue" to it pthread_create(&tid,...

  • Using Unix/Linux Command line in terminal and C programming. (b) Write a basic C program contained...

    Using Unix/Linux Command line in terminal and C programming. (b) Write a basic C program contained in a1q4.c and perform the following tasks in your program’s main() function: (8 marks) • Declare and initialize at least one variable of these types: char, int, unsigned int, float, double and long double. When initializing your variables, ensure the constants you use are of the same type as your variable. See the “Constants” section of Topic 7 for more information. • Use printf(3)...

  • Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing...

    Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing specific code. Global variables are often thought of as evil because the state of a system can be altered making functions execute differently when it isn't expected. There is also the issue of block scope. For an example of block scope, see the file below. Notice that you don't get an error because the code uses the correct syntax. Although the syntax is correct,...

  • Consider the following function definition and variable declarations: void square(int &n){n= n*n;} int arr[] = {1,...

    Consider the following function definition and variable declarations: void square(int &n){n= n*n;} int arr[] = {1, 2, 3}; int number = 4; Which of the following function calls are acceptable? (can have multiple answer) a.square(1); b.square(2); c.square(arr[number]); d.square(number); What is the output of the following code segment? int arr[] = {1, 4, 1, 0}; for (int i=0; i < 4; ++i)     cout<<arr[i]*2; a.1014 b.1 4 1 0 (space in between each number) c.1410 d.0140 e.None of the above Given...

  • Modify the below code to fit the above requirements: struct node { char data; struct node...

    Modify the below code to fit the above requirements: struct node { char data; struct node *next; struct node *previous; } *front, *MyNode, *rear, *MyPointer, *anchor *Valuenode ; typedef struct node node; int Push(char input) { if(IsFull()==1) {   printf("The queue is full. Enter the ‘^’ character to stop.\n"); return -1; } else if (IsFull()==-1) { node *MyNode=(node*)malloc(sizeof(node)); MyNode->data=input; rear->next=MyNode; MyNode->previous=rear; MyPointer=rear=MyNode; return 1; } else { node *MyNode=(node*)malloc(sizeof(node)); node *anchor=(node*)malloc(sizeof(node)); MyNode->data=input; MyPointer=rear=front=MyNode; MyNode->previous=NULL; MyNode->next=NULL; anchor->next=MyNode; return 0; } } char...

  • 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...

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