without using arithmatic operator convert an intger variable
x into x+1

Answer Posted / vadivel t

#include<stdio.h>

void main()
{
int no;
int size, i;

printf("ENTER THE NO: ");
scanf("%d",&no);

size = sizeof(int) * 8;
for(i = 0; i < size; i++)
{
if((no & (0x01 << i)) != 0)
{
no = no^(0x01 << i);
}
else
{
no = no |(0x01 << i);
break;
}
}
printf("OUTPUT :%d \n", no);
_getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is structure important for a child?

607


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

4846


Write a program to swap two numbers without using the third variable?

604


What are keywords c?

607


What is %g in c?

629






What is infinite loop?

632


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

588


Differentiate between calloc and malloc.

762


Explain threaded binary trees?

684


Is c is a procedural language?

602


any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above

649


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

635


Why do we use null pointer?

609


In a switch statement, what will happen if a break statement is omitted?

607


How do I create a directory? How do I remove a directory (and its contents)?

609