Question

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

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

1.

#include <stdio.h>

#include <stdlib.h>

int main()

{

int x=20;

float y=40.45;

double z=91.51e+5;

char w='A';

printf("%d %o %x \n",x,x,x);

printf("%f \n",y);

printf("%lf %e \n",z,z);

printf("%c \n",w);

return 0;

}

Output:

20 24 14 40.450001 9151000.000000 9.151000e+06 A

2.

#include <stdio.h>

#include <stdlib.h>

int main()

{

//part 1

double d=400.2345;

int i=(int)d; //converting double to int

printf("%d \n",i);

//part 2

int c=(int)'g';

c=c+8;

printf("%c \n",c);

//part 3

int a=20;

double b=10.62;

printf("%lf \n",a+b);

return 0;

}

Output:

400 o 30.620000

3.

#include <stdio.h>

#include <stdlib.h>

int main()

{

int x;

printf("Enter x: ");

scanf("%d",&x);

int y=3*x*x*x-5*x*x+6;

printf("You entered x=%d \n",x);

printf("y=%d \n",y);

return 0;

}

Output:

Enter x: 2 You entered x=2 y=10

Add a comment
Know the answer?
Add Answer to:
Problems: 1. Write a program to define the following variables, assign them values, and print their...
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 Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

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

  • USE Python 1. Assign value 555 to the variable x, write code to square the variable...

    USE Python 1. Assign value 555 to the variable x, write code to square the variable x and print out the result. 2. Given a string x, write a program to check if its first character is the same as its last character. If yes, the code should output "True" . 3. We defined two variables, x = 'Python' and y = '3.0'. Write code to concatenate the two numbers (the result should be 'Python3.0').

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

  • C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion:...

    C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion: code steps 1 thru 4 then test then add requirement 5, then test, then add 6, then test etc. Add comments to display assignment //step 1., //step 2. etc. This program is to have no programer created functions. Just do everything in main and make sure you comment each step. Create a program which has: 1. The following arrays created:                 a. an array...

  • Pointer tasks: ( In C++ ) 1. Write a program to store the address of a...

    Pointer tasks: ( In C++ ) 1. Write a program to store the address of a character variable and a float variable. • Print the address of both variables. • Print the values of variable using dereference operator. • Add 2 in float value using pointer. • Print address of character variable using reference operator. 2. Write a program that takes 5 elements in an array and print them in reverse order using pointers. 3. Write to program that takes...

  • programming language Write a program that will generate 5 random numbers between 20 and 80 and...

    programming language Write a program that will generate 5 random numbers between 20 and 80 and assign each to a variable of datatype double. You should use a random number generator seeded with time Using a series of if statements, determine which of the 5 variables contains the smallest value generated Print all five random numbers to the screen and print out the value that you determined was the smallest. All values should be printed with zero decimal places. 2.

  • Write a program(Python language for the following three questions), with comments, to do the following:   ...

    Write a program(Python language for the following three questions), with comments, to do the following:    Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

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

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