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 ...?
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.
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?
//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;
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.