C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
I am used break keyword to reduce the time complexity of program. If break keyword will not present then loop will continue even searching element has already found .
explan:- because if n starts with 0 the last element should be n-1 if we initialize i with 1 then last element n. suppose n=5; i=0; alloted memories are 0,1,2,3,4. 5 terms the last element is 4 i.e, equal to 5-1=4 => n-1.
Write a function, Iserach, which accepts the following parameters. arr, an array of integers n, the amount of elements in arr, and key, the integer being searched for
and performs a linear serach on arr for key . if key is found, your function should return the location in the array arr, where it was found. otherwise, it should return-1.
c variable gets assigned 1 if the element exists. else it prints the statement element not found. , you could also assign c=i, and as the i value will be the location of the element in the array. and print c value.
43 comments:
simple & clear program
why the hell have u used break;
How to Explain People about searching linear in array?
I hate programming. But this program is actually understandable
I am used break keyword to reduce the time complexity of program. If break keyword will not present then loop will continue even searching element has already found .
really appreciated,liked it,but where is header file............
good logic
is it running??
wow hw clever u using break.....bt wat the f*** i don get it...
really simple to understand..
hey bro, plz tell whether this can be shorten by using function calls??
can i get the prg using dynamic memory alllocation
program is not runnig dear.....
program is running clear
Thanx :)
this is an example of a good programer
thank u very much
ITS VERY SIMPLE AND UNDERSTANDABLE ONE
GOOD!!!!!!!!!!!!!!
if i give two same input and i need to print the memory location of the values will u plz send mr that prog
why are u confusing with
for(i=0;i<=n-1;i++),
we can write
for(i=1;i<=n;i++)
explan:-
because if n starts with 0 the last element should be n-1
if we initialize i with 1 then last element n.
suppose
n=5;
i=0;
alloted memories are 0,1,2,3,4. 5 terms
the last element is 4 i.e, equal to 5-1=4 => n-1.
Write a function, Iserach, which accepts the following parameters. arr, an array of integers
n, the amount of elements in arr, and
key, the integer being searched for
and performs a linear serach on arr for key . if key is found, your function should return the location in the array arr, where it was found. otherwise, it should return-1.
to get the position of the element found we should mention the position
so mention the position also.
can we use continue in place of break?
flowchart of linear search
can i possible return 0; = return 1; ???help me,please!
thnkzz mam .....ur program is helpful for any 1.......
superb program
What is the use of return 0;
u r doing very good work bro sreisly. Keep it up
tried..not working :(
its easy to understand... but what if an element is present more than once in the array....
prgrm nut shwng crc8 out put :p :p nd guyz dunt cpy nd past diz prgrm.....
Q) Write a program to identify keyword in 'c'
sample input: for
sample output: this is keyword
sample input: why
sample output: this is not keyword
what is c variable in code? please explain from if conditions
working perfectly
if the element is found, there is no need to check for remaining positioned elements
c variable gets assigned 1 if the element exists. else it prints the statement element not found. , you could also assign c=i, and as the i value will be the location of the element in the array. and print c value.
Right... i agree with you. This was my question also..
how to calculate time complexity?? means the best and the worst case of the execution??
example
Pie Sequence
example Pie Sequence
If there are two same numbers
Post a Comment