C :: How To Determine Whether A Logical Or Arithmetic Shift Is Performed
May 26, 2013
If input value was shifted to the right on bit level. How can I determine whether a logical or arithmetic shift is performed.
Code:
#include <stdio.h>
#include <stdlib.h>
void main ()
[Code]......
View 6 Replies
May 2, 2013
Question: State the values of each of these int variables after the calculation is performed. Assumed that, when each statement begins executing, all variables have the integer value 5.
a) product *= x++;
b) quotient /= ++x;
What is the answer for a and b?
View 4 Replies
View Related
May 1, 2013
Write a user-friendly C++ program that allows a user to select repeatedly an operation to be performed from a displayed menu of actions. The menu includes the following items:
1. Simple Statistics
2. Vector Addition
3. Dot Product
4. Exit
The menu actions are described by the following points:
Simple Statistics: This action includes finding the average, and standard deviation of a list of data items. The option should allow the user to specify the name of a file from which the data are read into an array. All the results of this option are displayed on the screen.
Vector Addition: This action allows the user to enter the name of a file from which two vectors, V1 and V2, of equal size N are read. Accordingly, the two vectors are added, and displayed along with the resultant vector on the screen. Your program should check that the two added vectors are of the same size. Otherwise, the program should display a message and allow the user to make another choice from the menu.
Dot Product: This action is similar to the Vector Addition in terms of input, output, and checking validity of the vector operands.
Exit: This action terminates the program.
Your program should include at least the following functions:
1. A function, called ReadVector(), which reads a vector of any size from a given file name, and returns the vector and its size to the caller. The function prototype is defined as follows:
void ReadVector(double V[], int &size, ifstream infile);
2. A function, called DisplayMenu(), which displays the menu and returns the user’s choice as an integer value between 1 and 4. The function prototype is defined as follows:
int DisplayMenu (void);
3. A function, called VectorAdd(), which performs the addition of two vectors, A and B, and returns the resultant vector, C. The function prototype is defined as follows:
void VectorAdd(const double A[], const double B[], double C[], int size);
The sum of two vectors, A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n, is defined as: C = A + B.
Where, C = (c1, c2, …, cn), and ci = ai + bi, for1 i n .
4. A function, called DotProduct(), which performs the dot product of two vectors, A and B, and returns the result. The function prototype is defined as follows:
void DotProduct(const double A[], const double B[], int size, double &result);
The dot-product of two vectors A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n is defined as
n n
n
i
i i b a ....... b a b a b a B . A
1 1 2 2
1
5. A function, called Simple_Stat(), which finds the maximum, minimum, average, and standard deviation of a list of data items passed to it by a one-dimensional array. The function returns the average and standard deviation values. The function prototype is defined as follows:
void Simple_Stat(const double list[], int size, double &average, double
&std_dev);
View 1 Replies
View Related
Feb 23, 2013
I am having this problem were the user types in a substring to search in the main string and replace it with another string
for example:
string: hello
sub string: el
replace: i
should print this: hillo
I tried using some string functions but I am having problems with that.
View 7 Replies
View Related
Jan 29, 2013
I need to circular right shift a cstring in C++
Let's say I have unsigned char test[10] = "HELLO!!!"; How would I go about circularly shifting this to the right? Inline assembly instructions would be ok too
View 6 Replies
View Related
Feb 10, 2015
I have this BCD string: 890123...78FFF and need to right shift by say 3 nibbles, resulting in: FFF890123...78
length is fixed, number of 'f' nibbles are varying.
View 3 Replies
View Related
Apr 24, 2012
when we are trying to shift one tab to other one event should occur, can any one tell what is the event,how and where we have to write the event? give example. if he successfully login in first tab only then second tab will open,if he doesnt login in first and tries to open the second tab message should appear...
View 1 Replies
View Related
Dec 20, 2013
I wrote this program using an online compiler i am getting a lot of errors.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
string birthmonth;
string birthday;
[Code] ....
View 6 Replies
View Related
Feb 24, 2012
I have a doubt in Left Shift Operator
int i = 1;
i <<= (sizeof (int) *8);
cout << i;
It prints 1.
Doubt:
i has been initialized to 1.
And while moving the bits till the size of the integer, it fills the LSB with 0's and as 1 crosses the limit of integer, i was expecting the output to be 0.
How and Why it is 1?
View 2 Replies
View Related
Mar 9, 2013
I've received a segmentation fault in this part of code:
Code:
for (; str[i] != '