Question

Assignment Output 2 to power n 2 to power-n 2 4 8 16 3 2 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 1OOOOO0ooo000 O.50O0OO0000OOO 0.250000000OOO O.125000ooooOO O.062500OoooOO O.031250OoooOO 0.015625000O00 O.00781250000O O.0039062500OO O.0019531250OO O.000976562500 O.000488281250 O.000244140625 O.0o0122070313 O.000061035156 O.0o0030517578 O.ooO015258789 O.ooO007629395 O.ooO003814697 O.ooO001907349 O.0oOO00953674 2 3 6 8 10 12 1 3 15 16 17 18 19 20

How to write a program to draw the output of a picture use c programming

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

CODE IN C:

#include <stdio.h>
#include<math.h>
int main()
{
//declaring variables to store the data
int n=20,i;
//displaying the lines and data as in the given output image
printf("\n-------------------------------------------------------");
printf("\n2 to power n\t\tn\t\t2 to power -n");
printf("\n-------------------------------------------------------");
//calculating power and displaying
for(i=0;i<=n;i++){
printf("\n%.f\t\t\t%d\t\t%.12f",pow(2,i),i,pow(2,-i));
}

printf("\n-------------------------------------------------------");
return 0;
}

OUTPUT:

2 to power n 2 to power -n 1.000000000000 0.500000000000 0.250000000000 0.125000000000 0.062500000000 0.031250000000 0.015625

Add a comment
Know the answer?
Add Answer to:
How to write a program to draw the output of a picture use c programming Assignment...
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
  • Microbial Growth Write out the microbial growth equation and then use it to perform the calculations...

    Microbial Growth Write out the microbial growth equation and then use it to perform the calculations for the following scenario: If there are 200 bacterial cells in some salad at 1:00 PM and they double every 20 minutes, how many bacteria will there be at 6:00 PM. 22 = 4 23 = 8 24 = 16 26 = 64 27 = 128 28 = 256 29 = 512 210 = 1024 211 = 2048 212 = 4096 213 = 8192...

  • implement a binary search function in 3 programming languages. In each program (identical, except for the...

    implement a binary search function in 3 programming languages. In each program (identical, except for the programming language), carry out the same 20,000,000 unsuccessful searches for eight different-sized arrays, namely arrays of sizes 128, 512, 2048, 8192, 32768, 131072, 524288, and 2,097,152. Measure in each of the three programs the time it takes to do the 20,000,000 searches for each of the eight arrays. Compare these timings to the theoretical timings the algorithm binary search provides. Are there differences between...

  • Week 5 Project Write a program that calculates the amount of money a person would earn...

    Week 5 Project Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, four pennies the third day, and continues to double each day. Output the amount earned each day .. and the total pay at the end. The Algorithm (Plan) for your program would be: Ask the user for the number of days to be...

  • write a program in java to print all the powers of 2 below a certain number...

    write a program in java to print all the powers of 2 below a certain number and calculate their sum. Make sure your program conforms to the following requirements. 1. Accept the upper limit from the user (as an integer). 2. These numbers grow very fast. make sure the sum variable is of the "long" type. You can assume that the test output will be less that LONG MAX. 3.Print all numbers as a running sum, and finally print their...

  • python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes...

    python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes an integer n as an argument. This function should display n to the user and prompt them to enter the number num that is the largest power of 2 less than or equal to n. Have your function return the user's input num (it will be used in the next problem) Problem 4 (Making a Game) Finally, create a main() function for your program....

  • Write a C++ program to calculate the value of y = x2 for all values of...

    Write a C++ program to calculate the value of y = x2 for all values of x where x = 1, 2, 3, 4, 5. Use nested FOR statement to calculate and display the results as shown on the table below. Compile and run the program then submit the CPP file. x y^2 a^3 a^4 a^5 1 1 1 1 1 2 4 8 16 32 3 9 27 81 243 4 16 64 256 1024 5 25 125 625...

  • C++ program Write a program which: 1. Enters data into the 2D array of integers which...

    C++ program Write a program which: 1. Enters data into the 2D array of integers which is 5x5 The data should be entered with an assignment statement using nested for loops that is do not scan in the data. The data should be: 1 2 4 8 16 1 3 9 27 81 1 4 16 64 256 1 5 25 125 625 1 6 36 216 1296 2. Print out the following using a nested for loop Row 0:...

  • ** Use Java programming language Program the following algorithms in JAVA: A. Classical matrix multiplication B....

    ** Use Java programming language Program the following algorithms in JAVA: A. Classical matrix multiplication B. Divide-and-conquer matrix multiplication In order to obtain more accurate results, the algorithms should be tested with the same matrices of different sizes many times. The total time spent is then divided by the number of times the algorithm is performed to obtain the time taken to solve the given instance. For example, you randomly generate 1000 sets of input data for size_of_n=16. For each...

  • Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input...

    Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input is ‘M’ or 'm', Female if the gender is ‘F’ or 'f', and invalid gender otherwise. 1) Declare variable, 2) draw your flow chart on the back, and 3) do the coding in C++.

  • Write a java program to print all the powers of 2 below a certain number and...

    Write a java program to print all the powers of 2 below a certain number and calculate their sum Requirements: 1. Accept the upper limit from the user as an integer 2. Make sure the sum variable is of the “long” type. You can assume that the test output will be less than LONG MAX. 3. Print all the numbers as a running sum, and finally print their sum. Please try and restrict yourself to loops, selection statements, and calls...

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