how to swap two integers 1 and 32767 without using third
variable
Answer Posted / g.sai lakshmi priyanka
void main()
{
int a,b;
a=32767,b=1;
a=a*b;
b=a/b;
a=a/b;
printf("%d %d",a,b);
}
EXPLAINATION:
a=32767*1=32767
b=32767/1=32767
a=32767/32767=1
a=1,b=32767
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Where are c variables stored in memory?
What is a far pointer in c?
What is spaghetti programming?
Explain what is gets() function?
What are the usage of pointer in c?
Write a program to print ASCII code for a given digit.
Explain what are reserved words?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
How do I use strcmp?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
When is a “switch” statement preferable over an “if” statement?
What is the difference between memcpy and memmove?
What is a stream in c programming?
write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.
What are the types of type specifiers?