[solved] – Question 92975

What will be printed by the following code?

int x=4;
repeat(4){ x = 2 * x + 3; }
cout << x << endl;

Expert Answer


[solved] – Question 92977

Give the statement which would enable you to create a rectangle having corners (10,30),(50,30), (10,80), (50,80). The rectangle should be given the name “r1”.

Expert Answer


[solved] – Question 92978

Fill in the blanks in the following code which is intended for drawing 5 circles of radius 50 pixels centered at points (100,100), (150,100), (200,100), (250,100), (300,100).

initCanvas();
double x=100;
repeat(5){
Circle c(x,___,___);
c.imprint();
x = x + ___;
}

Expert Answer


[solved] – Question 93008

Give the statement which would enable you to create a rectangle having corners (10,30),(50,30), (10,80), (50,80). The rectangle should be given the name “r1”.

Expert Answer


[solved] – Question 93016

If the size of the program counter is 16 bits, what can be the maximum size of the memory in computer architecture provided the data width is 8 bits?

Expert Answer


[solved] – Question 93017

Implement the following equation using 0-Address format instructions(using mnemonics)? 16+20+24+28-32

Expert Answer


[solved] – Question 93029

Write a program to input a text file name, read the contents of the file and create a new file named COPY.TXT, which shall contain only those words from the original file which don‟t start with an uppercase vowel (i.e., with „A‟, „E‟, „I‟, „O‟, „U‟). For example, if the original filecontains
The First Step To Getting The Things You Want Out Of Life is This: Decide What You Want. – Ben Stein

Expert Answer


[solved] – Question 93035

main_program{
int n; cin >> n;
double i= BlankA, term = BlankB, result = BlankC;
repeat(n){// On tth entry, t=1..n
// i=t-1, term=1/t!
// result=1/0!+..+1/(t-1)!
BlankD
}
cout << result << endl;
}

1)what is BlankA?
2)what is BlankB?
3)what is BlankC?
4)Which of the following will be correct in BlankD?

i = i + 1; term = term / (i+1); result = result + term;

result = result + term; i = i + 1; term = term / (i+1);

i = i + 1; result = result + term; term = term / (i+1);

term = term / (i+1); result = result + term; i = i + 1;

Expert Answer


[solved] – Question 93042

Consider the code below for calculating the value of e (Euler’s number/constant used in mathematics). It solves the same problem as discussed in the lecture but it does it differently. In the ith iteration it calculates the value of 1/i! and adds it to the result.

main_program{
int n; cin >> n;

double result = 0;
int i=__;

repeat(n){
// calculate 1/i!
int t=1;
double term = 1;
repeat(i){
term = term/t;
t = t + 1;
}
result = result + term;
i = i + 1;
}
cout << result << endl;

}

What should i be initialized to?

How many division operations does the above code do for n=10?

How many division operations did the code discussed in the lecture do for n=10?

Expert Answer


[solved] – Question 93043

One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)

x = [1,”abcd”,2,”efgh”,[3,4]] # Statement 1
y = x[0:50] # Statement 2
z = y # Statement 3
w = x # Statement 4
x[1] = x[1] + ‘d’ # Statement 5
y[2] = 4 # Statement 6
x[1][1] = ‘y’ # Statement 7
z[0] = 0 # Statement 8
w[4][0] = 1000 # Statement 9
a = (x[4][1] == 4)

Expert Answer