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

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

  • Sahithi Pallavi
    Sahithi Pallavi
    2. Write a C program without using Semicolon.

    #include
    #include
    main()
    {
    clrscr();
    if( printf("C program without Semi-Colon") ) {}
    getch();
    }

    Output : C program without Semi-Colon

    OR

    #include
    #include
    main()
    {
    clrscr();
    while( printf("CrazyEngineers"),0 ) {}
    getch();
    }

    Output : C program without Semi-Colon
  • Ankita Katdare
    Ankita Katdare
    No more takers for the questions?

    I was expecting more from programmers at CE. 😐
  • Sahithi Pallavi
    Sahithi Pallavi
    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
    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
    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
    @Akd : Please post the answers for unanswered questions!
  • TheV
    TheV
    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
    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
    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
    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.

You are reading an archived discussion.

Related Posts

How to display language bar in our computer? I want to type in Japanese in MS word.
Hey ppl, I couldn't stop noticing that a number of CEans are enjoying the user name change facility. Well, for me, i am little confused. So, lets start this thread...
https://www.crazyengineers.com/forum/general-help/36092-self-introduction-japanese-engineers.html https://www.crazyengineers.com/forum/general-help/36877-learn-japanese-pronunciations.html https://www.crazyengineers.com/forum/general-help/36234-japanese-similar-chinese.html https://www.crazyengineers.com/forum/general-help/35939-speaking-japanese-railway-station.html https://www.crazyengineers.com/forum/general-help/37071-speaking-japanese-restaurant.html https://www.crazyengineers.com/forum/general-help/26515-learn-japanese-easy-way.html https://www.crazyengineers.com/forum/general-help/26627-continued-learn-japanese-free-part-i.html https://www.crazyengineers.com/forum/general-help/26742-continued-learn-japanese-free-part-ii.html https://www.crazyengineers.com/forum/general-help/26792-continued-learn-japanese-free-part-iii.html https://www.crazyengineers.com/forum/general-help/26946-continued-learn-japanese-free-part-iv.html https://www.crazyengineers.com/forum/general-help/35782-come-crazyengineers-lets-speak-japanese.html https://www.crazyengineers.com/forum/general-help/38092-jlpt-past-years-question-papers-download.html
Friends, I will post Vocabulory words video in this thread for the first five words あ Pronounced as AA [video=youtube;G2ozAtrmHkU]https://www.youtube.com/watch?v=G2ozAtrmHkU[/video]
Eligibility Criteria for IT:​​​ Open only to the students with following degrees Category 1: BE / B Tech / ME / M Tech / MCA / M Sc (Computer Science...