To find whether a number is even or odd without using any
conditional operator??
Answer Posted / azad sable,chiplun.
void main()
{
int n;
clrscr();
printf("enter any no.");;
scanf("%d",&n);
if(n%2==0)/*remainder after division by 2*/
printf("\nthe no. is even");
else
printf("\nthe no. is odd");
}
getch();
}
| Is This Answer Correct ? | 10 Yes | 9 No |
Post New Answer View All Answers
What are types of preprocessor in c?
Explain void pointer?
How to establish connection with oracle database software from c language?
Is null valid for pointers to functions?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
Write a program to reverse a string.
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
what is the different bitween abap and abap-hr?
Explain the difference between null pointer and void pointer.
What are examples of structures?
What is difference between array and structure in c?
What is the maximum length of an identifier?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
Explain how do you print an address?
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.