CS Solved
CS Solved
CS Solved
Question No. 1: Write for a loop to populate array userGuesses with NUM_GUESSES integers. Read
integers using scanf. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then the output should be (9, 5, 2)
Question No.-2: Modify the following SQL command so that the rep_ID column is the primary key for the
table and the default value of Y is assigned to the column isActive:
Question No.-3: Write code for a function in C++ naming it reverseDigitwhich takes a positive or negative
integer value as a parameter and returns the number with its digits reversed.
For example the value of reverseDigit(532) should be 235 and if reverseDigit(-532) should be -235 .
Question No.-4 State the difference between the single-byte and burst modes in terms of the CE signal.
Question No.-5 Prove that if an edge is removed from a tree, the resulting graph is not a tree.
Answer No.-1:
Here in the table to assign a default value to the column (isActive) we have used the keyword DEFAULT and
assigned the default value in single quotes. In order to declare a column as primary key, the PRIMARY KEY
keyword is used and in the round brackets the name of the column is passed as an argument.
Answer No.-3:
Firstly we have to study the Mathematical concepts for reverse a number.
Let we have 532 so mathematically we can have convert it into 235 using following steps
Step1: We have to find modulus of 532
As the base of general number system is 10.
So
532 mod 10=2(say remainder)
Step 2: Let we have n=0
And n=n*10+remainder
We get n=0+2=2
Now we have 532/10=53.2
Its integer part is 53.
As we know the mod 10 will not convert the sign, This coding also valid for negative integer
So the C++ coding is
#include <iostream>
using namespace std;
int main()
{
int n, revNumber = 0, remainder;
while(n != 0)
{
remainder = n%10;
revNumber = revNumber*10 + remainder;
n /= 10;
}
cout<< "Reversed Number = " <<revNumber;
return 0;
}
Answer No.-4:
In Accessing SPI devices, we have two modes of operation, Single – byte and multibyte, We WILL Explain
each one Separately,
Single- Byte write
The following steps are used to send (write) data in single-byte mode for SPI devices, as shown in fig 16.2:
1. Make CE – 1 to begin writing.
2. The 8-bit address is shifted in one bit at a time, with each edge of SCLK, Notice that A7=1 for the
write operation, and the A7 bit goes in first,
3. After all 8 bits of the address are sent in, the SPI devices expects to receive the data belonging to
that address location immediately.
4. The 8-bit data is shifted in one bit at a time, write each of the SCLK.
5. Make CE-0 to indicate the end of the write cycle.
As the definition of tree - A connected graph (Let G) without any circuit is called a Tree. As well as
we have to understand two main properties to understand this question
First -Any two vertices in G can be connected by a unique simple path.
Second-G is connected but would become disconnected if any single edge is removed from G.
Let us study given below Tree (This graph is said to be tree as there is no circuit in this graph):
Now we observed that the resulting graph is not a tree as we above studied ‘A connected graph (Let G)
without any circuit is called a Tree’. So it is now disconnected so does not fulfil tree definition.