C Language Questions Asked in Technical Interviews - Try to answer them!

Ankita Katdare

Ankita Katdare

@abrakadabra Oct 27, 2024
I will be sharing different questions in this thread.

Its open for Engineers for all Branches.

TRY TO ANSWER THESE HERE:

1. Why don't we use multiple if statements instead of switch statement?

2. Write a C program without using Semicolon.

3. How to debug the infinite loop problem in output?

4. If we want to copy data from one file into another excluding the comments, how will you do it?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Pensu

    Pensu

    @pensu-8tNeGU Aug 22, 2011

    2. Write a C program without using Semicolon.

    #include<stdio.h>
    #include<conio.h>
    main()
    {
    clrscr();
    if( printf("C program without Semi-Colon") ) {}
    getch();
    }

    Output : C program without Semi-Colon

    OR

    #include<stdio.h>
    #include<conio.h>
    main()
    {
    clrscr();
    while( printf("CrazyEngineers"),0 ) {}
    getch();
    }

    Output : C program without Semi-Colon
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Aug 28, 2011

    No more takers for the questions?

    I was expecting more from programmers at CE. 😐
  • Sahithi Pallavi

    Sahithi Pallavi

    @sahithi-oJZaYj Aug 29, 2011

    1. Why don't we use multiple if statements instead of switch statement?
    By using the Switch statement the user can code as many statements by using Cases and the user executes any case that he wish while running the program. We can not do this with if. May be this is the reason. Correct me if I am wrong.

    3. How to debug the infinite loop problem in output?
    I am used to handle infinite loops with CTRL + Pause Break. Don't know whether they are any other methods to do that without using debugger.
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Aug 29, 2011

    Here are some more:

    Why are standard library functions used?

    What will happen if you do not include conio.h?

    What is the difference between a string copy (strcpy) and a memory copy (memcpy)?

    What is the use of preprocessor?

    How can I copy just a part of a string?
  • Jayesh.V

    Jayesh.V

    @jayeshv-1QOX4e Sep 1, 2011

    AbraKaDabra
    Here are some more:

    What will happen if you do not include conio.h?

    What is the difference between a string copy (strcpy) and a memory copy (memcpy)?

    How can I copy just a part of a string?
    1.conio.h represents the constant input and output statements, they are responsible for displaying the output in the screen they include certain basic functions like getch(); etc.

    2.strcpy copies the entire string and not its address or the memory location where as the memcpy copies the memory allocation

    3.substr() i guess am not sure though


    correct me if i am wrong 😀
  • Sahithi Pallavi

    Sahithi Pallavi

    @sahithi-oJZaYj Sep 1, 2011

    @Akd : Please post the answers for unanswered questions!
  • TheV

    TheV

    @thev-iGmS6y Sep 2, 2011

    I think if we use multiple ' if ' statement then it will increase the execution time of the program and also the program became lengthy.
    Execution increase because it will check each and every ' if ' statement even if the first ' if ' statement is true or executed. But in "switch case", it will take
    argument from the ' switch ' statement and directly jump to the specified ' case ' statement, executing only one ' case ' statement (break is given).
  • TheV

    TheV

    @thev-iGmS6y Sep 2, 2011

    Q) Why Standard Library Function is used ?

    Ans) C language provides a number of library functions which performs basic and very useful task like printing the output screen and some math function like sqrt and cos etc. If we not use these ready made functions then our program became complex and huge because if we want to calculate the square root of any number we just use the function sqrt() and not concern about what is written inside it, same with printf(). If we are not supplied with these function the coder have to write the code what is written in the printf() function which will make the program complex.

    Q) What is use of preprocessor ?

    Ans) From the word ' preprocessor ' it means that ' before '. That is it will take place before compilation. Before the source code passed to the compiler, the preprocessor checks for the preprocessor directives. If there are any, appropriate actions are taken, what the preprocessor defines i.e if it is #define X 10 it will replaces all X with 10, if it is #include it will include all the necessary file in the source code and the pass it to the compiler for further execution.
  • Sarath sharukh

    Sarath sharukh

    @sarath-sharukh-PGAkGs Nov 3, 2016

    Ankita Katdare
    I will be sharing different questions in this thread.

    Its open for Engineers for all Branches.

    TRY TO ANSWER THESE HERE:

    1. Why don't we use multiple if statements instead of switch statement?

    2. Write a C program without using Semicolon.

    3. How to debug the infinite loop problem in output?

    4. If we want to copy data from one file into another excluding the comments, how will you do it?
    1 switch case have certain cases but in if we can esyablish limits
  • Sabarishraj

    Sabarishraj

    @sabarishraj-ylAlcl Nov 3, 2016

    Google Self Driving Bicycle
    Google is introducing the Google Self Driving Bicycle in Amsterdam, the world’s premier cycling city. The Dutch cycle more than any other nation in the world, almost 900 kilometres per year per person, amounting to over 15 billion kilometres annually. The self-driving bicycle enables safe navigation through the city for Amsterdam residents, and furthers Google’s ambition to improve urban mobility with technology. Google Netherlands takes enormous pride in the fact that a Dutch team worked on this innovation that will have great impact in their home country.