C program debugging questions




















Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Please help debug C program Ask Question. Asked 7 days ago. Active 3 days ago. Viewed 71 times. Write a C program that prompts a user to input month day year student ID name birthday Run the program and store the data entered in a doc file which named by student number.

Gerhard 6, 7 7 gold badges 51 51 silver badges 79 79 bronze badges. It should return true when class C is derived from class P and false otherwise. Even an interviewee with only passing knowledge should write something similar to this, mostly likely involving a helper class:. It should compare class A and B and return false when they are different classes and true if they are the same class.

Although you can call an inline function from within itself, the compiler may not generate inline code since the compiler cannot determine the depth of recursion at compile time. A compiler with a good optimizer can inline recursive calls till some depth fixed at compile-time say three or five recursive calls , and insert non-recursive calls at compile time for cases when the actual depth gets exceeded at run time.

This program will terminate abnormally. The class A destructor will throw another exception during the exception handling, which will cause program to crash.

This question is testing if developer has experience working with exceptions. The method should be cross-platform compatible and not depend on sizeof int, bool, string. Create another class which has all the members of Something in the same order, but has additional public method which returns the value. Your replica Something class should look like:. Note: If it turns out that the alignment of the external library is mismatched to your code, you can resolve this using pragma pack.

Implement a void function F that takes pointers to two arrays of integers A and B and a size N as parameters. It then populates B where B[i] is the product of all A[j] where j! This will work for the given example, but when you add a 0 into input array A, the program will crash because of division by zero. The correct answer should take that edge case into account and look like this:.

The presented solution above has a Big O complexity of O N. While there are simpler solutions available ones that would ignore the need to take 0 into account , that simplicity has a price of complexity, generally running significantly slower.

So when you have a class class A which inherits from 2 parents B and C , both of which share a parent class D , as demonstrated below:. To fix this you need to change the declarations of classes C and B to be virtual, as follows:. This question is testing pointer arithmetic knowledge, and the magic behind square brackets with pointers.

If you said , you would have been correct if i had been declared as an int. However, since i was declared as an unsigned char , the corrct answer is that this code will result in an infinite loop. However, since i is an unsigned char , it is rerepsented by an 8-bit value which, after reaching , will overflow so it will go back to 0 and the loop will therefore go on forever. A class that specifies the life and scope of its variables and functions is called a storage class.

C debugging interview questions. C debugging questions with answers. Save the above. Let file name is close. Now close the turbo c compiler and open the directory in window you have saved the close. Course description Learn to develop embedded systems, interfacing electronic peripherals through real time projects and get required practical skills for software jobs. Course description Learn to develop software solutions for linux environment, implement requirements through real time projects and get required practical skills for software jobs.

Course description Learn, test your C programming skills and earn certificate for software jobs. Write a function to count the sum of all the digits present in an integer number Write a function to count number of characters present in a given string Write a function to count number of words present in a string Write a function to loop through the strings present in an array of pointers to string Program debugging: Given program will not always give output as Office?

Fix it Program debugging: Given program will not compile.



0コメント

  • 1000 / 1000