About Me

Hello there! Before talking about qualifications and professional abilities, I would like to introduce myself. I am a Yuvraj Basnet and professional software developer and have been working in this field for 3 long years. I have finished my graduation from The University of Delhi on Computer Science Engineering I considered myself a reasonably experienced programmer with a particular interest in the human side of software development, computers are fascinating machine, but they're mostly reflection of the people using them. In the art of software development, studying code isn't enough; you have to study the people behind the software, too.

PART III IMPORTANT QUESTIONS OF C

In this tutorial we will discuss about the 5 important questions of c.

Ques-1. what is datatype in C. Explain in detail ?


* Data types are data storage format that a variable can store a data to perform a      specific task. 

* Data types are declaration for variables.
* C is rich in data types.
* Size of the variable, constant and array are determined by data types.

Example- int myInt;

Here, myInt is a variable of int type 
the size of the int is 4 byte.

There are three classes of Data-type


A. Primitive Data-Type

B. Derived Data-Type
C. User Defined Data-Type

A. Primitive Data-Type:

  • In C, each variable has a specific data type,
  • Where data type tells us the sizerange and the type of a value that can be stored in a variable. 
  • There are about seven primitive data types in C.
  • These data types are short, long, int, char, float, double.


B. Derived Data-Type:
  • These data types are derived from fundamental(another) data types are called derived data types.
  • There are three derived data-types in C.
  • Array- A collection of data of same types or homogenous data type.
  • String- collection of data of character type.
  • Structure- A collection of related variables of same or different data types.
C. User Defined Data-Type:
  • Those data types which are defined by the user as per his/her requirement are called user-defined data types
  • Examples of such data types are structure, union and enumeration.
Ques-2. What is operator. Explain their types?

The symbols which are used to perform logical and mathematical operations in a C program are called C operators.
Types of operators:


A) ARITHMETIC OPERATOR-
The Arithmetic operators perform Arithmetic operations . The arithmetic operator can operate on any built in data types. A list of arithmetic operator and their meaning are given below.


B) RELATIONAL OPERATOR-

Relational operators are used to compare, logical, arithmetic and character expression. The whole expression involving the relation operator then evaluate to an integer. It evaluates to 0 if the condition is false and 1 if it is true. A list of relational operator and their meaning are given below.


C) LOGICAL OPERATOR-

A Logical operator is used to compare or evaluate logical and relational expression. A list of logical operator and their meaning are given below.


D) BITWISE OPERATOR-

These operators perform bit wise logical operations on values. Both operands must be of the same type and width: the resultant value will also be this type and width. A list of bitwise operator and their meaning are given below.


E) ASSIGNMENT OPERATOR-

An Assignment operator is used to form an assignment expression, which assigns the value to an identifier. A list of assignment operator and their meaning are given below.


F) CONDITIONAL OPERATOR-

The conditional expression can be used as shorthand for some if-else statements. Conditional operator is also called as ternary operator. This operator consist of two symbols: the question mark (?) and the colon (:).

SYNTAX -
Identifier = (test expression)? Expression1:
Expression2

SOME IMPORTANT DEFINITION-

OPERATOR PRECEDENCE-
              
If more than one operators are involved in an expression, C language has a predefined rule of priority for the operators. This rule of priority of operators is called operator precedence.

ASSOCIATIVITY OF OPERATOR- 

If two operators of same precedence (priority) is present in an expression, Associativity of operators indicate the order in which they execute.

 DEFINITION OF SPECIAL CHARACTERS -

Special characters are symbols (single characters or sequences of characters) that have a "special" built-in meaning in the language and typically cannot be used in identifiers.

Escape sequences are methods that the language uses to remove the special meaning from the symbol, enabling it to be used as a normal character, or sequence of characters when this can be done.

Ques-3. What is decision making and branching statement ?

Decision making statement: 



C programming is a set of statements or set of instructions, which are normally executed from the order in which they appear or written. This happens when no certain option or certain condition is used in programming. 

There may be a situations where we need to change the order of execution of statements and repeat execution of certain statements depending on conditions. That's why we use decision making and control statements.

C language support the following decision statements:
    
       1) if statement
       2) switch statement
       3) Conditional Operator statement
       4) goto statement

Branching Statement:

Branching statements allow the flow of execution to jump to a different part of the program. The common branching statements used within other control structures include: break, continue, return, and goto. The goto is rarely used in modular structured programming. Additionally, we will add to our list of branching items a pre-defined function commonly used in programming languages of: exit.

Ques-4. What is an array. Explain their types with suitable example ?

  • An array is defined as a finite collection of data of same types. 
  • or similar data items. All the data items of an array are stored in a consecutive memory location.
  • The elements of an array are of same data type and each item can be accessed using the same name.

OUTPUT

Types of an array:
1. One-dimensional array: An array which has only one subscript is known as one dimensional array.

Syntax: data_type array_name[s];
where data_type denotes the type of the elements in the array
array_name denotes name of the array. it must be a valid identifier.
(s) denotes number of elements an array can hold.


OUTPUT

2. Two-dimensional array: An array which has two subscript is known as two dimensional array.

Syntax: data_type array_name[r][c];
where data_type denotes the type of the elements in the array
array_name denotes name of the array. it must be a valid identifier.
[r] denotes the the row size of an array
[c] denotes the column size of an array.


OUTPUT









Ques-5 What is user defined function?

User-defined function:
  • User-defined function has to be developed by the programmer at the time of writing the program. 
  • Main is an example of user-defined functions.
Need of user-defined function:
  • It facilitate top-down modular programming.
  • The length of the source program can be reduced by using functions at appropriate places.
  • It is easy to locate and isolate a faulty function for further investigations.
  • A function can be used by many other programs.
Elements of user defined function:
  • Function definition
void mul()
{
    function body..
}
  • function call
int main()
{
    int a;
    mul();
    return 0;
}
  • function declaration
void mul();









Post a Comment

0 Comments