#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Posts
    1
    Rep Power
    0

    Mostly Asked C Interview Questions


    Can anyone share c language interview question and answers
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,971
    Rep Power
    509
    void reverse(char*pc, int length); /* reverse the characters in the array in place. */

    void anysort(int*array; int length); /* sort the array in place, low to high */
    For anysort it is known that the data in array take the values 0 through 100, but the length could be quite long.


    Show how to turn this program into an executable on the target (department's) operating system and environment.
    Code:
    #include<stdlib.h>
    #include<stdio.h>
    int main() {
      puts("hi world");
      return EXIT_SUCCESS;
    }
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,482
    Rep Power
    1876
    I wonder if 'indupriya1' will show up with some spammy site in response to this question, like they both did on cprogramming.com.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2017
    Location
    Chandigarh, India
    Posts
    4
    Rep Power
    0
    How will you print “Hello World” without semicolon?

    int main(void)
    {
    if (printf("Hello World")) ;
    }


    What is Dangling pointer?

    // EXAMPLE 1
    int *ptr = (int *)malloc(sizeof(int));
    .............
    .............
    free(ptr);

    // ptr is a dangling pointer now and operations like following are invalid
    *ptr = 10; // or printf("%d", *ptr);


    // EXAMPLE 2
    int *ptr = NULL
    {
    int x = 10;
    ptr = &x;
    }
    // x goes out of scope and memory allocated to x is free now.
    // So ptr is a dangling pointer now.


    What is memory leak? Why it should be avoided
    /* Function with memory leak */
    #include <stdlib.h>

    void f()
    {
    int *ptr = (int *) malloc(sizeof(int));

    /* Do some work */

    return; /* Return without freeing ptr*/
    }



    What are local static variables? What is their use?
    #include <stdio.h>
    void fun()
    {
    // static variables get the default value as 0.
    static int x;
    printf("%d ", x);
    x = x + 1;
    }

    int main()
    {
    fun();
    fun();
    return 0;
    }
    // Output: 0 1

    check out Smartphone application Development Company in Florida (Online Outsourcing Company)

IMN logo majestic logo threadwatch logo seochat tools logo