Very Short Questions Fall 2016 || Programming Language

Very Short Questions Fall 2016

Very Short Questions Fall 2016

The answers to the Very Short Questions Fall 2016 are given below:

1. What is constant? Write the different types of constant.

ANS- A constant can be defined in two ways, like #define pre-processor and by const keyword. The constants can be different data types, such as integer constants, floating constants, character constants, string constants and enumeration constants.

2. What is meant by the conditional operator?

ANS- Conditional operators are used to evaluate a condition that’s applied to one or two boolean expressions. The result of the evaluation is either true or false. There are three conditional operators: && the logical AND operator.

3. Define a global variable and local variable.

ANS- Local variable is declared inside a function whereas Global variable is declared outside the function. Local variables are created when the function has started execution and is lost when the function terminates, on the other hand, Global variable is created as execution starts and is lost when the program ends.

4. What is a function? Write the advantages of function

ANS- A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing. You have already seen various functions like printf () and main ().

5. Define a structure for a book and include its members like book_name, price and publication.

ANS- struct book_details {
int price;

string book_name;

}book_details;

6.List out the errors of the given program.
Void main()

{

Int v=10;*p;

P=v

Print(%d,*p0;

Getch()

}

ANS-

Void main()

{

Int v=10;*p;

P=v

Print(“%d”,*p);

Getch()

}

7. What does FILE * fp mean?

ANS- The FILE *fp declares a variable fp which is a pointer to a FILE and a function fopen which returns a pointer to a FILE.

8. Differentiate between variable type conversion?

ANS-

S.N. Type Casting Type Conversion
1 Type casting is a mechanism in which one data type is converted to another data type using a casting () operator by a programmer. Type conversion allows a compiler to convert one data type to another data type at the compile time of a program or code.
2 It can be used both compatible data type and incompatible data type. Type conversion is only used with compatible data types, and hence it does not require any casting operator.

9. Define identifier and write the rules for naming identifier.

ANS- Identifier is a name that is given to various program elements such as variables, symbolic constants, functions, structures or enums. The identifier is used to identify a user-defined item. The rules for naming identifiers are:

  • An identifier can only start with the letter (A-Z, a-z) or underscore( _ ) symbol.
  • An identifier can contain the alphabet, digits(0-9), and underscore only.
  • The identifier must not contain white spaces.
  • A keyword can not use as an identifier.

10. Write syntax for the do-while loop.

ANS- The syntax of a do…while loop in C programming language is:

do {
statement(s);
} while( condition );

You may also like Pokhara University || Fall ,2016 || Programming Language

Be the first to comment

Leave a Reply

Your email address will not be published.


*