Hi,

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

#include<stdio.h>

#include<math.h>

main ()

{ int x,y,z;

scanf("%d",&x);

scanf("%d",&y);

scanf("%d",&z);

x*=!z/4-(y*5%3)&&(3*y-!y)>=5;

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.

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

#include<stdio.h>

#include<math.h>

main ()

{ int x,y,z;

scanf("%d",&x);

scanf("%d",&y);

scanf("%d",&z);

x*=!z/4-(y*5%3)&&(3*y-!y)>=5;

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

Hi,

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

[1,3,5â€¦.]

I just need to know, what does he mean by odd indices ? Does he want pointers ?

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

[1,3,5â€¦.]

I just need to know, what does he mean by odd indices ? Does he want pointers ?

I just need to know, what does he mean by odd indices ? Does he want pointers ? |

http://en.wikipedia.org/wiki/Modulo_operation

i.e.

`(index % 1) == 1`

is odd
I really need help at the end of this code, it keeps giving me this error ..

#include<stdio.h>

#include<string.h>

#include<conio.h>

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]);

if(N[i][f-1]=='y'){count++;

printf("%d",count);

}}

char* temp;

for(int i=0;i<5;i++){if(N[i]<N[i+1]){strcpy(temp,N[i]);

strcpy(N[i],N[i+1]);

strcpy(N[i+1],temp);}}

for(int j=0;j<5;j++){ int max=0,z;

char* Nmax=N[0];

z=strlen(N[j]);

if(z>max)Nmax=N[j];

printf("the longest name is %S",N[j]);

printf("the location of the longest name is %d",&N[j]);}

for(int k=0;k<5;k++){

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,

#include<stdio.h>

#include<string.h>

#include<conio.h>

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]);

if(N[i][f-1]=='y'){count++;

printf("%d",count);

}}

char* temp;

for(int i=0;i<5;i++){if(N[i]<N[i+1]){strcpy(temp,N[i]);

strcpy(N[i],N[i+1]);

strcpy(N[i+1],temp);}}

for(int j=0;j<5;j++){ int max=0,z;

char* Nmax=N[0];

z=strlen(N[j]);

if(z>max)Nmax=N[j];

printf("the longest name is %S",N[j]);

printf("the location of the longest name is %d",&N[j]);}

for(int k=0;k<5;k++){

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.