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
Why is structure important for a child?
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.
Write a program to swap two numbers without using the third variable?
What are keywords c?
What is %g in c?
What is infinite loop?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
Differentiate between calloc and malloc.
Explain threaded binary trees?
Is c is a procedural language?
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
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
Why do we use null pointer?
In a switch statement, what will happen if a break statement is omitted?
How do I create a directory? How do I remove a directory (and its contents)?