Question

In: Computer Science

1. Design the logic for a program that outputs every multiple of 4, from 4 through...

1. Design the logic for a program that outputs every multiple of 4, from 4 through 100
along with its value squared and cubed, e.g.,
The next number: 4
Squared: 16
Cubed: 64
The next number: 8
Squared: 64
Cubed: 512

Solutions

Expert Solution

//I am presenting the logic in c language

#include <stdio.h>

int main()
{
for(int i=4;i<=100;i=i+4)//loops from 4 to 100 increments by 4 at a time
{
printf("The next number:%d\n",i);//the number
printf("Squared:%d\n",i*i);//sqaure of number num * num
printf("Cubed:%d\n",i*i*i);//cube of a number num * num * num
}

return 0;
}


Related Solutions

design a logic circuit that counts the number of 1s in 12 inputs(a0...a11) and outputs a...
design a logic circuit that counts the number of 1s in 12 inputs(a0...a11) and outputs a 4-bit binary that represents the count of 1s. for example, if input is 111111111111 which has 12 1s, then output should be 1100 note :Do not use clocking. draw logic diagram.
Trace through the program and what the outputs will be. If there is an error explain...
Trace through the program and what the outputs will be. If there is an error explain what must be fixed and continue to trace through. #include <iostream> using namespace std; void beans(int y, int& n, int size); void spam(int& n, int& y); int main(){ int m = 7; int n = 4; cout<<"m is "<<m<<" n is "<<n<<endl; beans(n, m, 3); cout<<"m is "<<m<<" n is "<<n<<endl; spam(m, n); cout<<"m is "<<m<<" n is "<<n<<endl; beans(m, 2, n); cout<<"m is...
1. Design a combinational logic circuit that converts 4 bits binary to gray code 2. Design...
1. Design a combinational logic circuit that converts 4 bits binary to gray code 2. Design a combinational logic circuit that converts gray code to 4 bits binary 3. Design a combinational logic circuit that converts 4bits 2421 to excess 3 code
Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
Design a PLC ladder logic program to control a stop light. The program should have 3...
Design a PLC ladder logic program to control a stop light. The program should have 3 outputs: RED, YELLOW, and GREEN. The ladder logic should illuminate green for 60 seconds, then yellow for 10 seconds, then red for 60 seconds. The system should also have two sensor inputs: THROUGH_TRAFFIC and CROSS_TRAFFIC which detect when there is through traffic and cross traffic present. If through traffic is detected, and no cross traffic is detected, the system should maintain a green light...
Design the logic for a program that has two parts: The user enters 15 numbers that...
Design the logic for a program that has two parts: The user enters 15 numbers that are stored into an array. The program uses the array to display the numbers back to the user in reverse order. You must use an array and one or more loops to get full credit. Can someone please help me figure this out?
Can someone please walk through this program for me and explain out the outputs are generated....
Can someone please walk through this program for me and explain out the outputs are generated. #include <iostream> #include <iomanip> using namespace std; const int size = 5; int fun(int arz[size], int jump) { int i, j = 0; for(i = 0; i < size; i += jump) j += arz[i]; return j; } main() { int arx[size] = {1, 2, 4, 8, 16}; int ary[size] = {10, 20, 40, 80, 160}; cout << fun(arx, 1) << endl; cout <<...
Design the logic for a program that has two parts. The user enters 15 test scores...
Design the logic for a program that has two parts. The user enters 15 test scores (values between 1-100) that are stored in an array. The program uses the array to compute and output the following statistics minimum maximum average Write this in pseudocode.
Design and test a 4-bit rotator that has two inputs: A and rotamt, and two outputs...
Design and test a 4-bit rotator that has two inputs: A and rotamt, and two outputs Yleft and Yright using (System) Verilog. The rotation amount (number of bits to be rotated) is given in rotamt and the output of left and right rotation will be in Yleft and Yright, respectively.
CHAPTER 7 Problem 4  Programmable Logic Controllers Study the ladder logic program in Figure 7-41 and answer...
CHAPTER 7 Problem 4  Programmable Logic Controllers Study the ladder logic program in Figure 7-41 and answer the questions that follow: a. What type of timer has been programmed? b. What is the length of the time-delay period? c. What is the value of the accumulated time when power is first applied? d. When does the timer start timing? e. When does the timer stop timing and reset itself? f. When input LS1 is first closed, which rungs are true and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT