write an expression

I need some help writing this program, I tried my best to understand the question and write it by C++ language but it keeps giving me an error
Here's the question :

Write complete C++ program that will read three integer values x, y and z from keyboard then compute the following expressions independently.?

z = (2√y + ‘B’ /y) && (x-- -2 )
and here's what I've done
main ()
{ int x,y,z;
z=2*(sqrt(y))+ "B"/y)&&(x-- -2);

this is the error 9 invalid operands of types `const char[2]' and `int' to binary `operator/'

I hope you would be able to answer my message as soon as possible,
thank you.
Last edited on
don't use "" instead like suggested '':

z=(2*sqrt(y) + 'B'/y)&&(x-- -2); // Notice the brackets
Last edited on
Thank you very much !
I have a question, Write a complete C/C++ program to do the following:
1-Define static array called A of size 8 of type double, read all elements from
keyboard then compute and print the product of all elements that found in odd indices
I just need to know, what does he mean by odd indices ? Does he want pointers ?
No, not pointers. You can determine wheter the index is odd with the modulus operator:


i.e. (index % 1) == 1 is odd
I really need help at the end of this code, it keeps giving me this error ..
int main (){
char N[5][31];
for(int i=0;i<5;i++){ scanf("%s",&N[i][31]);}
int f;
int count=0;
for(int i=0;i<5;i++){ f=strlen(N[i]);
char* temp;
for(int i=0;i<5;i++){if(N[i]<N[i+1]){strcpy(temp,N[i]);

for(int j=0;j<5;j++){ int max=0,z;
char* Nmax=N[0];
printf("the longest name is %S",N[j]);
printf("the location of the longest name is %d",&N[j]);}

if(strcmp(N[k],"Ali")==0)strcpy("N[k]",{'S','a','m','i','\0'}); }
getch(); }

and the error is 27 expected primary-expression before '{' token
Thank you in advance,
You main is an int function which does not return any value either change to void or return 0.The program will work though i see a logical error
Last edited on
Topic archived. No new replies allowed.