In the following control structure which is faster?
1.Switch
2.If-else
and which consumes more memory?
Answer Posted / vignesh1988i
as for as me is concerned switch is faster....
in if-else first it will check the if condition , if it is
true it's no problem.. but if it falls false, it will go
to the else part ...
but in switch case , the argument given inside switch
statement will see and automatically to the necessary case
of it... so by comaring the time constraint ,switch saves
the time for checking each else statement for every if....
thank u
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Explain what is meant by high-order and low-order bytes?
Tell me when is a void pointer used?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What does a pointer variable always consist of?
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.
How can I find the modification date of a file?
What do you mean by recursion in c?
Is c dynamically typed?
What is the most efficient way to store flag values?
Explain what is the advantage of a random access file?
Is main is a keyword in c?
What are enumerated types?
Do you know what are the properties of union in c?
What is the best way of making my program efficient?
I need testPalindrome and removeSpace
#include