thanks to both of you guys you were right the variables needed to be of the char type and the sugestion to seperate the (scode =='r') and the (scode == 'R') statements was exactly what i needed to do thanks it was a subtle change in the syntax but exactly what was needed you guys are life savers!

Study operator precedence. I know it's boring as hell, think of it as the same kind of thing as learning your times tables -> boring as hell but great to know once you know. It helps a lot to be able to look at an expression and know what order it will be evaluated in.

What it was doing before was evaluating scode == "p" first. If that was true, the whole expression is true because it's logical or (look up short-circuit evaluation).

If scode is not equal to "p", then it evaluated whether "P" is true, which it always is, because "P" is not a null pointer. A literal string evaluates to the pointer to the first character of the string. Therefore the if condition is always true.

ok see i havent learned anything about pointers as of yet and didnt realize that literal strings evaluate to there relitive pointers, so thank you for that information that will help alot. as far as the logic gose i wanted it to evaluate the "p" first if that was true to run the if statement if not true to check wether the "p" was true. i have an ok understanding of operator precedence the biggest issue was realy a matter of not understanding the way strings evaluate so swiching to char instead of strings was a perfect solution. setting up the boolien the way it is now should tell the compiler the same thing as before shouldn't it? its only realy differant synacticaly right? which was another of my issues i have been programing in python for some time now and am not used to c++ syntax. thanx again though for your help you really saved me. i was really worried i wouldnt get this assignment done.

setting up the boolien the way it is now should tell the compiler the same thing as before shouldn't it? its only realy differant synacticaly right?

Not sure what you mean by "the way it is now" but if you mean like gerard4143's comment, yes that works. I simply explained how the compiler interpreted it the way you originally had it, so you'd know why your original code didn't work.

At first knowing other languages is going to bog you down a little, but soon that's going to turn around and make you able to learn new languages even faster. Programming languages are more alike than they are different, and knowing several sharpens your eye to the kinds of issues that you encountered in this post.

yah i was refering to setting the boolien up as if(scode == ('r' || 'R')) as apposed to if((scode == 'r') || (scode == 'R')). the logic of these two staements and oder in which i expected them to evaluate seems the same to me. firs if the 'r' portion is true and if not then if the 'R' portion is true. the only real differance i see is syntax. however if there is somthing i am missing or not understanding about how the order of precidence differs between them, i would verry mutch appreciate any help youd be willing to offer. thanx again for your post

Character literals evaluate to the ascii value of the character. scode == 'A' is exactly the same thing as scode == 65.

Boolean expressions are calculations. When you evaluate 2 * 2 == 4, the result is the number 1. When you say 2 * 3 == 4, the result is the number 0.

In C, when it is evaluating boolean (true or false) types of expression (in 'if', 'while', 'for' etc), the whole expression is true if the answer is not zero, and it is false if the answer is zero.

When evaluating scode == ('r' || 'R')) this is the order of operations:

- 'r' || 'R' means the following: if 'r' != 0 then the result is 1, else if 'R' != 0 then the result is 1, else the result is zero

so this is how it would break down:

(scode == ('r' || 'R')
simplifies to (scode == (114 || 82))

when it evaluates 114 || 82, it is essentially a calculation that means, if ((114 is not equal to 0) or (82 is not equal to 0)) then the result is 1, else the result is zero.

114 is not equal to zero, which means it is true. Expressions in C use short-circuit evaluation, so using logical OR, there is no need to evaluate the right hand side, because it is OR, 114 is already true. it can (and WILL) skip the other side of the evaluation because true OR anything is still true.

ok so the statement (scode == ('r' || 'R')) checks if 'r' or 'R' is a numerical value != to zero, were as the statement if((scode == 'r') || (scode == 'R'))checks the relationship between the variable and the numerical value because of the grouping symbols its going to evaluate dose ('r' || 'R') = true ?, where as (variable == 'char') || (variable == 'char') allows for evaluation of two relational statements right?

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...