Question

Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and...

Write a C program that will do the following:

1.Declare four integers variables.   intVar1, intVar2, intVar3,and intVar4.

2. Initialize intVar1 to the value 4; initialize intVar2to the value 5.

3. Declare four more integer variables. exp1, exp2,exp3, and exp4.

4. Declare a character variable charVar.

5. Assign the value of each expression below to variables exp1and exp2 respectively:

exp1= intVar1 + ((5 * intVar2) / (3 * intVar1));

exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1;

6. Using the fprintf()function, print to standard output the values of the variables (your output should look like the following):

intVar1= 4 and intVar2 = 5

Expression values are: exp1 = 6 exp2 = 24

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

int main() {
    //1.Declare four integers variables.   intVar1, intVar2, intVar3,and intVar4.
    int intVar1, intVar2, intVar3, intVar4;
    
    //2. Initialize intVar1 to the value 4; initialize intVar2 to the value 5.
    intVar1 = 4;
    intVar2 = 5;
    
    //3. Declare four more integer variables. exp1, exp2,exp3, and exp4.
    int exp1, exp2,exp3, exp4;
    
    //4. Declare a character variable charVar.
    char charVar;
    
    //5. Assign the value of each expression below to variables exp1and exp2 respectively:
    exp1 = intVar1 + ((5 * intVar2) / (3 * intVar1));
    exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1;
    
    //6. Using the fprintf()function, print to standard output the values of the variables (your output should look like the following):
    
    //intVar1= 4 and intVar2 = 5
    //Expression values are: exp1 = 6 exp2 = 24
    
    fprintf(stdout, "intVar1 = %d and intVar2 = %d\n", intVar1, intVar2);
    fprintf(stdout, "exp1 = %d exp2 = %d\n", exp1, exp2);
    
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Write a C program that will do the following: 1.Declare four integers variables.   intVar1, intVar2, intVar3,and...
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
  • Write a complete C program that does the following: . o Declare a and b as...

    Write a complete C program that does the following: . o Declare a and b as character variables. Initialize a to this value: 127 o Declare c as an unsigned character variable o Multiply a by 2 and store the result in variable b. o Multiple a by 2 and store the result in variable c. Print the values of a, b, and c. Use the %d specifier in each case. Declare d as an integer variable. Initialize d to...

  • Please code in c 1. Write a program which does the following: Declare and initialize three...

    Please code in c 1. Write a program which does the following: Declare and initialize three pointers. One points to an integer, one points to a float and one points to a character variable Ask the user to enter appropriate values for these variables. Output the values to the screen by accessing the variables directly and then by using pointer references. Print the address of each variable. Modify the variables by performing any arithmetic operation only using pointer refer- ences...

  • Problems: 1. Write a program to define the following variables, assign them values, and print their...

    Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...

  • Question 16 (4 points) Write a complete C program that declares four variables of type integer...

    Question 16 (4 points) Write a complete C program that declares four variables of type integer (i.e integer variables) and four variables of type pointer to integer (i.e. integer pointers). Assign the addresses into the pointers. Using the indirection operator with a pointer, assign the values 1, 2, 3, and 4 into the four integers. (Use the indirection operator with the pointers to write the integer values.) Your program should write the addresses and values of all eight variables to...

  • Write in C++ Implement a program that can input an expression in postfix notation (see Exercise...

    Write in C++ Implement a program that can input an expression in postfix notation (see Exercise C-5.8) and output its value. As you can see, you will need to read Exercise C-5.8 to complete this programming task. Exercise C-5.8 Postfix notation is an unambiguous way of writing an arithmetic expression without parentheses. It is defined so that if “(exp1) o (exp2)” is a normal fully parenthesized expression whose operation is “o”, then the postfix version of this is “pexp1pexp2o”, where...

  • Write a complete C++ program that will: Declare a vector of integers Use a pointer to...

    Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...

  • C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point...

    C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize...

  • I'm using code blocks to perform this. These problems are from my C Programming Beginners book....

    I'm using code blocks to perform this. These problems are from my C Programming Beginners book. Not too familiar with C programming so any help would be great. I would like to see how it is formatted. Also, I don't understand Problem 4 at all. Thanks. 1- Create three integer variables and initialize to zero. 2- Create three float variables and initialize to zero. 3- Create three double variables and initialize to zero. 4- Create one character variables and initialize...

  • Write a complete C++ program to ask the user to enter 4 integers. The program must...

    Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the smallest integer among them and print it on the screen. Typical output screen should be as following: Write a complete C++ program to ask the user to enter 4 integers. The program must use a functionto find the smallest integer among them and print it on the screen. Typical output screen should be as following: Note: the code...

  • 1. Declare an array of five integers named boxes. 2. what do you type to access...

    1. Declare an array of five integers named boxes. 2. what do you type to access the third element in the boxes array? 3. what do you type to assign the number 10 to the 5th element in the boxes array? 4. Declare an array named cartons that contains these values: 4.2 , 3.1, 6.8 5. what is the subscript value of 6.8 in the cartons array? 6. what will this program output if is in a complete program? cout<<...

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
Active Questions
ADVERTISEMENT