How to write foreach with AND Condition?

Question 2: Write a condition for each of the following: a) Testing a number n is even. b) Testing a char?

  • Question 2: Write a condition for each of the following: a) Testing a number n is even. b) Testing a char c) Testing a number n is odd and positive or n is even and negative. d) Testing a string st is the not the same of "Nothing". ,,, Computer Programming c++ !

  • Answer:

    Hi.. Here are your answers: a) int N; if(N%2==0) cout<<""Even"; else cout<<"Odd"; b) if(sizeof(c)==1) cout<<"It is a char"; c) int N; if(N%2!=0&&N>0) cout<<"Odd and positive"; else if(N%2==0&&N<0) cout<<"Even and negative"; d) char str[10]="Nothing"; if(!strcmp(str,"Nothing") cout<<"It is same as nothing"; Please ask questions on C/ C++ at my blog: http://cplusplusatoz.blogspot.in/

Wafa at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.