Question

READ and FOLLOW all directions (post a screenshot of the code if possible and proof that...

READ and FOLLOW all directions

(post a screenshot of the code if possible and proof that the program can run)

C++ code language, using FOR and WHILE loops, and ARRAY to solve

CLEAN CODE IS A MUST! WRITE FOR READABILITY

1. Write a program that converts decimal number to hexadecimal

1a) Write a program using nested loops that asks the user to enter a value for the number of rows to display. It should display that many rows as asteriks with 1 asterik in the first row, 2 in the second row, and so on. However the last asterik in each row should be aligned (PRECEDED BY SPACES) (DO NOT USE SET PRECISION)

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

1. Program that converts decimal number to hexadecimal

Code in c++:

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

long int decnum, rem, quot;

char hexdecnum[100];

int i=1, j, temp;

cout<<"Enter any decimal number : ";

cin>>decnum;

quot=decnum;

while(quot!=0)

{

temp=quot%16;

if(temp<10)

{

temp=temp+48;

}

else

{

temp=temp+55;

}

hexdecnum[i++]=temp;

quot=quot/16;

}

cout<<"Equivalent hexadecimal value of "<<decnum<<" is : \n";

for(j=i-1; j>0; j--)

{

cout<<hexdecnum[j];

}

getch();

}

1a)

#include <iostream>

using namespace std;

int main()

{

int rows = 0;

int less = 1;

cout << "Enter number of rows: ";

cin >> rows;

for(int i=0; i < rows; i++)

{

for(int d=0; d < (rows - less); d++)

cout << ".";

for(int a=0; a < less; a++)

cout << "*";

cout << endl;

less++;

}

return 0;

}

Add a comment
Know the answer?
Add Answer to:
READ and FOLLOW all directions (post a screenshot of the code if possible and proof that...
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
  • Follow exactly all the instructions provided below: Do not deviate from the instructions provided below or...

    Follow exactly all the instructions provided below: Do not deviate from the instructions provided below or add any unnecessary code to program. Pay close attention to the directions! Make absolutely certain that you are doing exactly what the assignment asks you to do without any more code required. Keep the program's code as simple as possible and begineer friendly level with no advanced level Java concepts/skills. Write a program that asks the user for a number. The program should check...

  • Use HCS12 assembly language only - not C code Using CodeWarrior to create a new project...

    Use HCS12 assembly language only - not C code Using CodeWarrior to create a new project that uses assembly language. Write an assembly program that turns on the red LED at the beginning. It switches to off 2 seconds later and switches back to on after three more seconds. (That is, it stays on for 2 seconds and off for 3 seconds.) This switching process lasts forever. Use a loop (or nested loops) for each of the 2/3-second delay where...

  • I am having trouble figuring out why my program will not make any columns, just rows....

    I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...

  • Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a...

    Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a method that computes and returns the area of a square using the following header: public static double area ( double side) Write a main method that prompts the user to enter the side of a square, calls the area method then displays the area. Question 1a: Write a method that converts miles to kilometers using the following header: public static double convertToKilometers (double miles)...

  • Choose 3 of 5 Problems to Solve Need Soon as possible Choose 3 of5 Problems to...

    Choose 3 of 5 Problems to Solve Need Soon as possible Choose 3 of5 Problems to Solve (20 Point/Each) Problem l: Triangle Printing Program: Write an application that prints a right triangle with 1 to 8 rows. Prompt the user to enter an odd number in the range of 1 to 8 to specify the number of rows in the diamond. Add a validation loop to ensure the user does not enter an even number or a number outside the...

  • Hi. Please help me solve this in python using only while loops, if statements. Can't use...

    Hi. Please help me solve this in python using only while loops, if statements. Can't use for loops and lists. In this programming assignment, you will be writing a program that prints out several shapes via text. In this PA, you will be required to use functions and parameters. This is both to reduce redundancy and to make your code clean and well-structured. Name your program shaper.py Your program should have the capability to print out three different shapes: An...

  • Directions: Complete all the three programming assignments below. Please be sure to follow the programming rubric...

    Directions: Complete all the three programming assignments below. Please be sure to follow the programming rubric provided. Turn in three separate “.py" files. Be sure to run your programs before submission. Color Mixer The colors red, blue, and yellow are called primary colors, because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here: • When you mix red and blue, you get purple. • When you mix...

  • Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a...

    Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a file called Numbers.txt in your the same folder as your Python program. This file should contain a list on floating point numbers, one on each line. The number should be greater than zero but less than one million. Your program should read the following and display: The number of numbers in the file (i.e. count them) (counter) The maximum number in the file (maximum)...

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • Write the C# code and make a screenshot of the output according to tasks given below:...

    Write the C# code and make a screenshot of the output according to tasks given below: Create a class named Prism with protected data fields named height and volume (Use double data type for the fields) [5 points] Include public properties for each field. The Height and Volume properties should have get and set accessors. [5 points] Add default constructor which sets the value of Height and Volume properties to 1 and 1 respectively. [5 points] Add overloading constructor which...

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