Search:

Type: Posts; User: jbode; Keyword(s):

Page 1 of 3 1 2 3

Search: Search took 0.12 seconds.

  1. Answers
    1
    Views
    1,673

    Re: Want to know the working of this program.

    The behavior of "c = a++ + ++a + a++;" is undefined; the result will vary based on the compiler, optimization settings, surrounding code, etc.

    The problem is that the order in which each...
  2. Re: Write a function that counts the negative numbers in a list of integers using c++

    Instead of writing a separate function, use what's available in the standard library:



    #include <algorithm>
    #include <functional>
    #include <vector>
    ...
    vector<int> v;
    // load values into v
  3. Answers
    5
    Views
    2,481

    Re: fibonecii series in C++

    Here's a slightly different approach. It uses the generate_n template function to generate a Fibonacci sequence and stores the resulting sequence to a vector, from which we compute the sum and...
  4. Answers
    3
    Views
    9,087

    Re: switch case vs if else

    First of all, never blindly assume that one method is always going to be faster than the other; code up both versions and measure their relative performance.

    Once you've made that measurement,...
  5. Answers
    5
    Views
    2,481

    Re: fibonecii series in C++

    The following code will compute and display either a single Fibonacci number, or a range of Fibonacci numbers and the average of that range, using the computation by rounding method, which uses the...
  6. Thread: null pointer

    by jbode
    Answers
    3
    Views
    1,900

    Re: null pointer

    The null pointer is a well-defined "nowhere" that is guaranteed to compare unequal to any valid memory address. It can be used in several different ways:


    Indicate an error condition - standard...
  7. Thread: Array Index

    by jbode
    Answers
    3
    Views
    1,388

    Re: Array Index

    In C, array indexing is defined in terms of an offset from a base address; the expression a[i] is evaluated as *(a+i). The first element of the array is found at the base address, so the offset is 0...
  8. Thread: c++

    by jbode
    Answers
    3
    Views
    1,501

    Re: c++

    There is a difference between function overloading and function overriding.

    You can overload a function or method by declaring or defining multiple functions or methods with the same name in the...
  9. Thread: C Basics

    by jbode
    Answers
    3
    Views
    1,668

    Re: C Basics

    You might find this to be an interesting read.

    Giving it a quick scan, I'm not sure if Ritchie says so explicitly, but the first C compiler was either written in PDP assembler or B.
  10. Thread: return(a,b,c)

    by jbode
    Answers
    3
    Views
    7,353

    Re: return(a,b,c)

    Neither C nor C++ support the idea of tuples the way Perl or Python do. Not only can functions not return them, there's no way to assign them. If you need a function to return multiple values, you...
  11. Answers
    3
    Views
    16,738

    Re: How to Clear Input Buffer

    Contrary to the answers you've gotten so far, you do not want to use fflush to clear an input stream. From the C Language Standard:


    Emphasis mine. Calling fflush on an input stream may clear...
  12. Answers
    3
    Views
    1,866

    Re: Count the Occurence C Sample

    I know this thread is over 5 years old now, but I figured I'd go ahead and post an example.

    This program goes a bit above and beyond the initial request in that it scans for all C keywords, rather...
  13. Thread: gets

    by jbode
    Answers
    3
    Views
    1,397

    Re: gets

    The best way to explain why gets is unsafe is to look at its declaration:


    char *gets(char *s)

    gets takes a pointer to a buffer and copies input from the standard input stream to that buffer...
  14. Thread: Basics of c

    by jbode
    Answers
    3
    Views
    1,780

    Re: Basics of c

    The standard libraries are as much a part of the C language as the grammar. Note that there are two types of execution environments, hosted and freestanding. A hosted environment is what most of us...
  15. Thread: Object Slicing

    by jbode
    Answers
    1
    Views
    852

    Re: Object Slicing

    First problem: obj1 is of type A, which doesn't have the member variable y; assigning obj2 to obj1 doesn't change obj1's *type*.
    Second problem: B declares y as a protected member; it wouldn't be...
  16. Re: Why pointers are used in C and C++ but not in Java and C#

    First of all, Java and C# use pointers all over the place; they just don't expose any pointer operations to the programmer the way C and C++ do. The designers of Java and C# felt that pointer...
  17. Answers
    7
    Views
    5,300

    Re: Pre Increment and Post Increment

    Expressions of the form ++i * ++i and ++i + ++i result in undefined behavior, meaning any result is possible. An object may have its value modified at most once between any two sequence points by...
  18. Answers
    3
    Views
    971

    Re: Recursion Program Example

    Sorting algorithms such as the Quicksort algorithm take advantage of recursion, as do binary tree traversal algorithms.

    Many fractals such as the Koch snowflake and the SIerpinski gasket are...
  19. Answers
    4
    Views
    4,724

    Re: structure and union

    A struct will have memory allocated for all its members, accounting for alignment (IOW, there may be some padding bytes between members so that all members are properly aligned).

    Take the...
  20. Re: What is the real use of these Public,Private and Protected in developing a progra

    Think about a class that has to maintain some internal state, like a data structure or a file stream. Allowing other code direct access to that internal state data runs the risk of corrupting the...
  21. Answers
    12
    Views
    13,715

    Re: Differences Between Method and Function

    The terms method, function, procedure, subroutine, and subprogram are all roughly synonymous, although the term function is generally reserved for a subroutine that returns a value. Some languages...
  22. Thread: c program

    by jbode
    Answers
    7
    Views
    3,047

    Re: c program

    Basically, it will evaluate as


    5 - ((-11 * 2) / 4)
    == 5 - (-22 / 4)
    == 5 - (-5 )
    == 10
  23. SQL Re: Find Employees Who Does Not Belong to Any Department

    If an employee is not a member of any department, then you're looking for EIDs that appear in the Employee table but not in the EmpDept table:



    select e.eid, e.name from employee e where e.eid...
  24. Thread: c program

    by jbode
    Answers
    7
    Views
    3,047

    Re: c program

    Remember the following:


    The expression x++ evaluates to the current value of x, which is 5;
    The expression --y evaluates to the current value of y - 1, which is -11;
    The expression --y * b...
  25. Answers
    3
    Views
    2,258

    Re: Return value for a leaf function

    Reformatting and adding some line numbers to assist in the discussion below


    /* 1 */ int leaf(int f)
    /* 2 */ {
    /* 3 */ int result;
    /* 4 */ result = f-1;
    /* 5 */ if (f<5)
    /* ...
Results 1 to 25 of 55
Page 1 of 3 1 2 3
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact