pattern.cpp
#include<iostream>
using namespace std;
void printCross(int n)
{
int i,j,k;
if(n%2) //odd number of lines
{
for(int i=n;i>=1;i--)
{
for(int j=n;j>=1;j--)
{
if(j==i || j==(n-i+1))
cout<<j;
else
cout<<" ";
}
cout<<"\n";
}
}
else //even number of lines
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(j==i || j==(n-i+1))
{
cout<<" "<<j<<" ";
}
else
cout<<" ";
}
cout<<"\n";
}
}
}
void printForwardSlash(int n)
{
if(n%2)
{
for(int i=n;i>=1;i--)
{
for(int j=n;j>=1;j--)
{
if(j==n-i+1)
{
cout<<j;
}
else
cout<<" ";
}
cout<<"\n";
}
}
else
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(j==(n-i+1))
{
cout<<j;
}
else
cout<<" ";
}
cout<<"\n";
}
}
}
void printBackwardSlash(int n)
{
if(n%2) // odd number of lines
{
for(int i=n;i>=1;i--)
{
for(int j=n;j>=1;j--)
{
if(j==i)
{
cout<<j;
}
else
cout<<" ";
}
cout<<"\n";
}
}
else //even number of lines
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(j==i)
{
cout<<j;
}
else
cout<<" ";
}
cout<<"\n";
}
}
}
int main()
{
int num;
char ch;
cout<<"Create a numberes shape that can be sized."<<endl;
cout<<"Input an integer [1,50] and a character [x,b,f]."<<endl;
cin>>num>>ch;
if(ch=='x' || ch=='X')
printCross(num);
else if(ch=='f' || ch=='F')
printForwardSlash(num);
else if(ch=='b' || ch=='B')
printBackwardSlash(num);
else
cout<<"\nWrong input"<<endl;
return 0;
}
OUTPUT
Input a number [1-50] representing the size of the shape and then a character [x,b,f] which...
Design a circuit with three input variables x y z representing the bits in a binary numbers and three outputs( a, b and c) also representing bits in a binary numbers when the inputs 0, 1, 6 or 7. The binary output will be complement of the input when the binary input is 2, 3, 4, or 5. The output is the input shifted left with a rotation( Example 3 = 011, outputs 001)
(Matlab) Suppose we have a function “hw5f.m” that takes as input
x and outputs the value for a function f(x). Write a Matlab program
that inputs: • interval [a, b]; • m, the number of data points with
evenly spaced nodes from x1 = a to xm = b, and values from f(x); •
location z satisfying x2 < z < xm−1, where h = (b − a)/(m −
1); and outputs the value of the interpolaton polynomial using only...
Design a combinational logic circuit which has one output Z and a 4-bit input ABCD representing a binary number. Z should be 1 iff the input is at least 5, but is no greater than 11. Use one OR gate (three inputs) and three AND gates (with no more than three inputs each). Using K-map, find min SOP and min POS form for the outputs W, X
Please show the steps 1. Write the minimum SOP expression of F(A,B,C)=∑(2,3,4,6) with “don't-care” conditions, d(A,B,C)=(0,1,5) 2. Write the minimum POS expression of F(A,B,C,D)=Π(2,3,11,12,15) with don't-care conditions, d(A,B,C,D)= (0,7,10,14) 3. What is the critical path delay for the given logic circuit? Assume that a 2-input OR gate has a propagation delay of 21 ns, the 2-input AND gate has a propagation delay of 14 ns, and the NOT gate has a propagation delay of 9 ns. A. 58 ns B. 57 ns...
part c
Problem 3 [10 points a) (5 points) Construct a circuit that takes as input a 3-bit number X-XXXo and increments it by one. L.e. if the input is 101 the output should be 110. Use only half adders. b) Construct a circuit that takes as input a 3-bit number X-XXxo and decrements it by one 1. (5 points) Show the truth table of the circuit. Then use a decoder and additional gates to implement it. So Ys Y2...
1. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately terminating the list reading when the sentinel value (lets use -9999) is entered. The program should then correctly report the number of non-negative scores entered and the arithmetic mean (average) of those scores 2. Demonstrate your programs behavior in response to errors on input (that is, show that it faithfully rejects improper input such as alphabetic characters, decimal points, and commas). Here are some...
,,1. Which of the following statments are valid C++ statements? A) cout << "Hello World" : B) cout << Hello World; C) cout << "Hello " << "World" ; D) cout << "Hello" << "World" ; 2. What is the difference between the literals 'A' and "A"? ,3. Read the input from user; Check for valid entries If input is invalid: print an error message; else: calculate the result and print to the console; exit; The code snippet above may...
1. (15 pts) Simplify the following Boolean functions using K-maps: a. F(x,y,z) = (1,4,5,6,7) b. F(x, y, z) = (xy + xyz + xyz c. F(A,B,C,D) = 20,2,4,5,6,7,8,10,13,15) d. F(A,B,C,D) = A'B'C'D' + AB'C + B'CD' + ABCD' + BC'D e. F(A,B,C,D,E) = (0,1,4,5,16,17,21,25,29) 2. (12 pts) Consider the combinational logic circuit below and answer the following: a. Derive the Boolean expressions for Fi and F2 as functions of A, B, C, and D. b. List the complete truth table...
Exercise 6: Given the table of the function f(x)-2" 2 X 0 3 2 f(x) 1 2 4 8 a) Write down the Newton polynomials P1(x), P2(x), Pa(x). b) Evaluate f(2.5) by using Pa(x). c) Obtain a bound for the errors E1(x), E2(x), Es(x) Exercise 7: Consider f(x)- In(x) use the following formula to answer the given questions '(x) +16-30f+16f,- 12h a) Derive the numerical differentiation formula using Taylor Series and find the truncation error b) Approximate f'(1.2) with h-0.05...
1.
a. Design and implement a combinational circuit with three
inputs w, x, and y and three outputs A, B and C using CMOS
transistors. When the binary input is 0, 1, 2 or 3 the binary
output is three greater than the input. When the binary input is 4,
5, 6 or 7 the binary output is three less than the input.
b. from the part (a) , Draw the mask layout with Ln = Lp= 0.6
μm, Wn=...