C programming questions and answers pdf free download






















The constant "" is a string constant containing the characters 1, 2, and 3. Question 07 What is the function of the semicolon in a C statement? Answer: It is the statement terminator. Related Papers.

By Brian Icalina. By shiqing li. By Mohammed Tammam. By Deepak gusain. By Dulce Rubi Dolores Martinez. Download pdf. Log in with Facebook Log in with Google. Remember me on this computer. Instead, the operator! While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a single line.

Some programmers prefer this method as a way of organizing codes to make it look clearer, especially in conditional statements. Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program.

Simply put, commands that you use in C programming are actually functions that are defined from within each header files. Each header file contains a set of functions. For example: stdio.

To store , you can use? You can also use? Yes, it? For example: you can have a code like? Since each header file contains different function definitions and prototype, you would be using only those header files that would contain the functions you will need. Declaring all header files in every program would only increase the overall file size and load of the program, and is not considered a good programming style.

When declaring functions, you will decide whether that function would be returning a value or not. If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then? When a return value is expected after the function execution, the data type of the return value is placed instead of? Compound statements are made up of two or more program statements that are executed together.

Compound statements can also be executed within a loop. This is a common mistake for programmers, often leading to logical errors. Random numbers are generated in C using the rand command. What could possibly be the problem if a valid function name such as tolower is being reported by the C compiler as undefined?

The most probable reason behind this error is that the header file for that function was not indicated at the top of the program. Header files contain the definition and prototype for functions and commands used in a C program. In the case of? This format is used for two things: to set the number of spaces allotted for the output number and to set the number of decimal places.

The number before the decimal point is for the allotted space, in this case it would allot 10 spaces for the output number. If the number of space occupied by the output number is less than 10, addition space characters will be inserted before the actual output number. The number after the decimal point sets the number of decimal places, in this case, it?

Instead, use the strcpy function. The correct statement would be: strcpy myName,? How do you determine the length of a string value that was stored in a variable?

To get the length of a string value, use the function strlen. Yes, you don? Source codes in C are saved with. C file extension. Header files or library files have the. H file extension. Every time a program source code is successfully compiled, it creates an. OBJ object file, and an executable. EXE file. Reserved words are words that are part of the standard C language library. This means that reserved words have special meaning and therefore cannot be used for purposes other than Explain What it is originally intended for.

Examples of reserved words are int, void, and return. A linked list is composed of nodes that are connected with another. In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.

Binary trees are actually an extension of the concept of linked lists. A binary tree has two pointers, a left one and a right one. Each side can further branch to form additional nodes, Explain Which each node having two pointers as well. All reserved words must be written in lowercase; otherwise the C compiler would interpret this as unidentified and invalid.

You cannot use reserved words as a user-defined variable. One may think that INT is a reserved word and must not be used for other purposes. Explain However, recall that reserved words are express in lowercase, so the C compiler will not interpret this as a reserved word. This is used to insert a new line when displaying data in the output screen. A newline escape sequence can be placed before the actual output expression or after.

It is the process of transferring data to an alternative output source other than the display screen. Output redirection allows a program to have its output saved to a file. These 2 functions basically perform the same action, Explain Which is to get the absolute value of the given value. Abs is used for integer values, while fabs is used for floating type numbers.

Also, the prototype for abs is under , while fabs is under. Write a simple code fragment that will check if a number is positive or negative. It is used to convert any letter to its upper case mode. Toupper function prototype is declared in. Note that this function will only convert a single character, and not an entire string.

The strcat function. It takes two parameters, the source string and the string value to be appended to the source string. Do these two program statements perform the same output? Yes, they both do the exact same thing, Explain Which is to accept the next key pressed by the user and assign it to variable named letter.

Text files contain data that can easily be understood by humans. It includes letters, numbers and other characters. On the other hand, binary files contain 1s and 0s that only computers can interpret. Yes, it is possible to create a customized header file. Just include in it the function prototypes that you want to use in your program, and use the include directive followed by the name of your header file. Dynamic data structure provides a means for storing data more efficiently into memory.

Using dynamic memory allocation, your program will access memory spaces as needed. This is in contrast to static data structure, wherein the programmer has to indicate a fix number of memory space to be used in the program. Explain How would you place this character as part of the output on the screen? For example, you can write printf? Storing data on the heap is slower than it would take when using the stack. Explain However, the main advantage of using the heap is its flexibility.

Slowness in the heap can be compensated if an algorithm was well designed and implemented. Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, Explain Which would depend on Explain What functions are to be used in the program.

We also divide all the c programming questions to multiple levels. Levels are nothing but complexity and toughness of programming questions. Therefore all the c programming questions are also separated by the categories.



0コメント

  • 1000 / 1000