Showing posts with label C Language. Show all posts
Showing posts with label C Language. Show all posts

Monday, December 5, 2022

Noble University IMCA and BCA C Language Question Bank

 
----------------------------------------------------------------------------------------------------------------------------

Prepared By : Uday Shah (HOD - IT)

Mobile No : 7600044051

E-Mail : rupareleducation@gmail.com


Question Bank Unit 1

1 – Marks

1. Give full form : ANSI

Ans : American National Standard Institute

2. Give definition: Algorithm.

Ans : algorithm is a procedure or Step by Step instruction for solving program.

3. What is a dry run?

Ans :  A dry run is the process of a programmer manually working through their code to trace the value of variables

4. What is a flowchart?

Ans : A flowchart is a type of diagram that represents a workflow or process.

5. Give the difference between ++m and m++ notation.

Ans : ++m is Pre Increment and m++ is Post Increment

6. What is the range of character datatype in the C programming language?

Ans : -128 to 127

7. Explain the scanf () function.

Ans : Scanf function is used to input data from keyboard.

8. How many bits are occupied by the character datatype?

Ans : 1 Byte

9. What is the output?

#include<stdio.h>

#include<coni.h>

void main()

{

int k=65;

printf(“%c %d”, k, k );

}

Ans : A65

10.What is a header file consist of?

Ans : Library Function

11.What is the return data type of scanf()?

Ans : int

12.Why should we use i++ rather than i=i+1?

Ans : i++ execute fast in compare to I = I + 1

13.What is the difference between local and global variable declaration in C?

Ans : Scope of the Variable, Local variable scope limited while global variable scope is entire program.

14.What is Enumeration?

Ans : Enum is User Define Data Type

15.C Language consists of ______ number of keywords.

Ans : 32

16.C is middle–level language. [True/False]

Ans : True

17.C programming is _____ (top-down/bottom-up) programming.

Ans : top to down

18.Operators in C language are classified into ________

Ans : 6 Type

19.Types of comment available in C language is/are _________

Ans : Two 1. Single Line Comment and 2. Multiline Comment

20.C supports as many as _______relational operators.

Ans : 6 Types


Question Bank Unit 2

 1 – Marks


1. Which loop executes at least one?

Ans : do wile loop

2. List out iterative control statements in the c programming language.

Ans : For, While and Do while

3. ____________ statement will terminate the current execution of a loop.

Ans : break

4. Which two loops are known as entry control loops?

Ans : For and While

5. What is the “break” keyword?

Ans : it is use to terminate the current execution.

6. When if statements are nested, the last else gets associated with the nearest if without an else. (T/F)

Ans : False          

7. The _______ operator is true only when both the operands are true.

Ans : And

8. Multiway selection can be accomplished using an else if statement or the __________ statement.

Ans : Switch

9. Each expression in the else if must test the same variable. (T/F)

Ans : True

10.The ______ statement when executed in a switch statement causes immediate exit from the structure.

Ans : Break

11.Find errors, if any, in each of the following segments:

if (x + y = z && y > 0)

printf(“ “);

Ans : Error : if( x+y == z && y > 0)

12.In a pretest loop, if the body is executed n times, the test expression is executed n + 1 times. (T/F)

Ans : True

13.The number of times a control variable is updated always equals the number of loop iterations. (T/F)

Ans : False

14.Both the pretest loops include initialization within the statement. (T/F)

Ans : True

15.In an exit-controlled loop, if the body is executed n times, the test condition is evaluated ________times.

Ans : n +1

16.The _________statement is used to skip a part of the statements in a loop.

Ans : continue

17.for loop with the no test condition is known as ______ loop.

Ans : infinite loop

18.The sentinel-controlled loop is also known as _______ loop.

Ans : While loop

19. In a counter-controlled loop, variable known as _____ is used to count the loop operations.

Ans : index 

Question Bank Unit 3

1 – Marks

1. Explain the strlen () function.

Ans : String Length Function or It calculate number of character in an array.

2. Mathematical functions are stored in ________ header file.

Ans : math.h header file

3. Define a function in C.

Ans : A function is a group of statements that together perform a task.

4. What is an Argument?

Ans : The values that are declared within a function when the function is called are known as an argument.

5. How to pass an array to a user-defined function?

Ans : To pass an entire array to a function, only the name of the array is passed as an argument

6. A function in C should have atleast one return value. (T/F)

Ans : True

7. Explain the getchar () and putchar () functions.

Ans : Here the getchar() function takes a single character from the standard input and assigns them to a ch variable. Whereas the putchar() function prints the read character

8. What is “end-of-string” marker?

Ans : EOF

9. What is the meaning of w and s in scanf(“%ws”, string1);

Ans : W is whitespace character and S is String

10.How to read line of text from user.

Ans : using gets() function.

11.What is the rerturn type of getchar() function?

Ans  : int

12.Explain gets() function.

Ans : To read line of text from user.

13. Explain putchar() with example.

Ans : Putchar is a function in the C programming language that writes a single character to the standard output stream

14.Explain the use and functionality of atoi(string) function.

Ans : The atoi() function converts a character string to an integer value.


Question Bank Unit 4

1 – Marks

1. Define array.

Ans : An array is a data structure that contains a group of elements.

2. What is an array variable?

Ans : Array variables provide an alternative to defining multiple variables to represent multiple values.

3. How to declare one dimentional array?

Ans : datatype variablename[size];

4. An array can store similar datatypes of value. (T/F)

Ans :  we can store similar datatype only in an Array.

5. Explain multidimentional array.

Ans : datatype variablename[Row_Size][Col_Size];

6. An expression that evaluates to an integral value may be used as a subscript. (T/F)

Ans : True

7. In C, by default, the first subscript is zero.(T/F)

Ans : True

8. The declaration int x[2] = {1,2,3}; is illegal.(T/F)

Ans : True

9. The variable used as a subscript in an array is popularly known as _______variable.

Ans : Index

10.An array can be initialized either at compile time or at___________.

Ans : Run Time

11.An array that uses more than two subscript is referred to as ______________array.

Ans : Two Dimension

12._____ Keyword is used to create a structure.

Ans : struct

13.In structure, the. (dot) the operator is used for what?

Ans : Member Access

14.The structure is a collection of different data types. Is this true or false?

Ans : False

15. Structures may contain members of only one data type. (T/F)

Ans : False

16. Structures are always passed to functions by printers.(T/F)

Ans : True

17.Pointers can be used to access the members of structure variables. (T/F)

Ans : True

18.We can perform mathematical operations on structure variables that contain only numeric type members. (T/F)

Ans : False

19.The________ can be used to create a synonym for a previously defined data type.

Ans : Typedef

20.The selection operator —> requires the use of a __________to access the members of a structure.

Ans : Pointer Operator

21.The variables declared in a structure definition are called its ____________.

Ans : Member of Structure


Question Bank Unit 5

1 – Marks

 

1. Pointer variables are declared using the address operator.

Ans : False

2. Pointer constants are the addresses of memory locations.(T/F)

Ans : True

3. Pointers to pointers is a term used to describe pointers whose contents are the address of another pointer. (T/F)

Ans : True

4. It is possible to cast a pointer to float as a pointer to integer.

Ans : No

4. An integer can be added to a pointer. (T/F)

Ans : True

5. A pointer can never be subtracted from another pointer.

Ans : Yes

5. When an array is passed as an argument to a function, a pointer is passed. (T/F)

Ans : False

6. Pointers cannot be used as formal parameters in headers to function definitions. (T/F)

Ans  : False

7. Value of a local variable in a function can be changed by another function.(T/F)

Ans : True

8. A pointer variable contains as its value the________ of another variable.

Ans : Memory Address

9. The ___________operator is used with a pointer to de-reference the address contained in the pointer.

Ans : *

10. The __________only integer that can be assigned to a pointer variable is ____________

Ans : 0 and NUll

11. The pointer that is declared as ________cannot be de-referenced.

Ans : Void

12. What is a NULL pointer?

Ans : A null pointer is a special reserved value which is defined in a stddef header file. Or

Null means that the pointer is referring to the 0th memory location.




Wednesday, October 5, 2016

C Language Short Question


Prepared By : Uday Shah - HOD(IT)

Contact No : 7600044051

C PROGRAMMING HISTORY:

The C language is a structure oriented programming language, was developed at Bell Laboratories in 1972 by Dennis Ritchie. C language features were derived from an earlier language called “B” (Basic Combined Programming Language – BCPL). C language was invented for implementing UNIX operating system.

C PROGRAMMING BASICS:

Steps to be followed for any C program to create and get the output are explained . This is common to all C programs and there is no exception, whether its a very small C program or very large program. Structure of a C program is defined by a set of rules called protocol, to be followed by programmer while writing a C program.

C – PRINTF AND SCANF:

printf() and scanf() functions are inbuilt library functions in C which are available in the C library by default. These functions are declared and related macros are defined in “stdio.h” which is a header file. We have to include “stdio.h” file as shown in below C program to make use of these printf() and scanf() library functions.

C – DATA TYPES:

C data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before using in a program. Size of variable, const and array are determined by data types. There are four data types in the C language. They are.



C – DATA TYPES:

Types
Data Types
Basic data types
int, char, float, double
Enumeration data type
Enum
Derived data type
pointer, array, structure, union
Void data type
void


C – TOKENS AND KEYWORDS:

C tokens, Identifiers and Keywords are the basics in a C program. All are explained in this page with definition and simple example programs. C tokens are the basic building blocks in C language which are constructed together to write a C program. Each program element in a C program is given a name called identifiers.

C – CONSTANTS:

C Constants are also like normal variables. But, the only difference is, their values can’t be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals. Constants may be belonging to any of the data type.

C – VARIABLES:

C variable is a named location in a memory where a program can manipulate the data. This location is used to hold the value of the variable. The value of the C variable may get changed in the program. The C variable might be belonging to any of the data types like int, float, char etc.

C – OPERATORS AND EXPRESSIONS:

The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators, functions, constants and variables are combined together to form expressions.  

C – DECISION CONTROL STATEMENTS:

In decision control statements (C – if else and nested if), group of statement is executed when the condition is true.  If the condition is false, then, else part statements are executed. In C programming, there are 3 types of decision making control statements in C language. If Statement, if else statement  and nested if statements.

C – LOOP CONTROL STATEMENTS:

Loop control statements in C programming are used to perform looping operations until the given condition is true. Control comes out of the loop statements once the condition becomes false. There are 3 types of loop control statements in C language. For Loop, While Loop and Do while Loop.

C – CASE CONTROL STATEMENTS:

The statements which are used to execute only specific block of statements in a series of blocks are called case control statements. There are 4 types of case control statements in C programming. They are 1) switch 2) break 3) continue 4) goto.



C – TYPE QUALIFIERS:

The keywords which are used to modify the properties of a variable are called type qualifiers. There are two types of qualifiers available in C programming. They are 1) const 2) volatile. Constants are also like normal variables.

C – STORAGE CLASS SPECIFIERS:

Storage class specifiers in C programming tell the compiler where to store a variable, how to store the variable, what is the initial value of the variable and the lifetime of the variable. There are 4 storage class specifiers available in C language.  Local , Global , Static and Register  

C – ARRAY:

C Array is a collection of variables belongings to the same data type. You can store group of data of the same data type in an array. There are 2 types of arrays in C programming. They are 1) One dimensional array 2) Multidimensional array.

C – STRING:

C Strings are nothing but array of characters ended with null character (‘\0’). This null character indicates the end of the string. In C programming, strings are always enclosed by double quotes. Whereas, character is enclosed by single quotes in C.

C – POINTER:

C Pointer is a variable that stores/points the address of the other variable. C Pointer is used to allocate memory dynamically,  i.e. at run time. The variable might be any of the data types such as int, float, char, double, short etc. Normal variable stores the value, whereas pointer variable stores the address of the variable.



C – FUNCTIONS:

Functions in C programming are basic building blocks in a program. All C programs are written using functions to improve re-usability, understandability and to keep track of them. A large C program is divided into basic building blocks called C function. C function contains set of instructions enclosed by “{  }” which performs specific Task.

C – LIBRARY FUNCTIONS:

Library functions in C language are inbuilt functions which are grouped together and placed in a common place called a library. Each library function in C programming language performs a specific operation. We can make use of these library functions to get the pre-defined output instead of writing our own code to get those outputs.

C – COMMAND LINE ARGUMENTS:

main() function of a C program accepts arguments from command line or from other shell scripts by following commands. They are 1. argc 2. argv[]. In real time application, it will happen to pass arguments to the main program itself.  These arguments are passed to the main () function while executing binary file from command line.