1) What is the use of printf() and scanf() functions?
printf(): The printf() function is used to print the integer, character, float and string values on to the screen.
Following are the format specifier:
- %d: It is a format specifier used to print an integer value.
- %s: It is a format specifier used to print a string.
- %c: It is a format specifier used to display a character value.
- %f: It is a format specifier used to display a floating point value.
scanf(): The scanf() function is used to take input from the user.
2) What is the use of a static variable in C?
Following are the uses of a static variable:
- A variable which is declared as static is known as a static variable. The static variable retains its value between multiple function calls.
- Static variables are used because the scope of the static variable is available in the entire program. So, we can access a static variable anywhere in the program.
- The static variable is initially initialized to zero. If we update the value of a variable, then the updated value is assigned.
- The static variable is used as a common value which is shared by all the methods.
- The static variable is initialized only once in the memory heap to reduce the memory usage
3) What is the use of the function in C?
Uses of C function are:
- C functions are used to avoid the rewriting the same code again and again in our program.
- C functions can be called any number of times from any place of our program.
- When a program is divided into functions, then any part of our program can easily be tracked.
- C functions provide the reusability concept, i.e., it breaks the big task into smaller tasks so that it makes the C program more understandable.
No comments:
Post a Comment