• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

answer for the program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
write a basic program in any language weather its C,C++ ,

when i given an input as 1 it should display 0,if the input is 0 the result should be 1,
the conditions are should not use conditions and arithmetic operators ...?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not allow conditions or arithmetic?

Would array look-up or substring extraction be allowed?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi karthikeyan ravi, welcome to the ranch ! This place is NotACodeMill, so you should DoYourOwnHomework.

Do you mean that it should be in either C or C++ ? If so, I'll move your question to the C/C++ forum.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple substraction can help here. If the input is 1 the output should be 0. If the input is 0 the output should be 1. That means that input + output == 1. I'm sure you can now find out what to assign to the output based on the input.
 
T Dahl
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Simple substraction can help here. If the input is 1 the output should be 0. If the input is 0 the output should be 1. That means that input + output == 1. I'm sure you can now find out what to assign to the output based on the input.


Subtraction would count as arithmetic, wouldn't it?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about boolean operators?
 
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Easiest way i see would be an array of two elements.

But of course we don't really have a good definition from the OP.

Are conditional opeators allowed?

Or boolean operations?

Or even bit masks?

Once again - hard to say when we do not get the full requirements...
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//using logical NOT operator
#include<iostream.h>
int main()
{
int a;
cout<<"enter the value i.e 0 or 1"<<endl;
cin>>a;
cout<<"the opposite is"<<!a<<endl;

return 1;
}
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

k. mahesh kumar wrote:
cout<<"the opposite is"<<!a<<endl;
}



I think casting is required here....

cout<<"the opposite is "<<(int) !a<<endl;
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

T Dahl wrote:

Rob Prime wrote:..


...



Really thought that Rob Spoor is a different one from Rob Prime until now...
 
Ranch Hand
Posts: 97
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the possible solutions:-


Regards,
Gaurav
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read about you and your book, and I like to be selected by chance I have to do a project for a company, and your book would serve me much help, save me time looking for solutions in the network.

A question I ask you, if you have taken a long time and headaches, writing this book?

A greeting and good luck with the book, and all followers of this forum just to say that cane to keep giving these keyboards.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marco,

As already pointed out here you may have posted your question about the book in its own thread.
 
Gaurav Sagar
Ranch Hand
Posts: 97
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more is using the bitwise exclusive OR operation:-


Regards,

Gaurav
reply
    Bookmark Topic Watch Topic
  • New Topic