0% found this document useful (0 votes)
143 views

C Programming and Data Structures - CS3353 - Important Questions With Answer - Unit 1 - C Programming Fundamentals

Uploaded by

ROHISIVAM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

C Programming and Data Structures - CS3353 - Important Questions With Answer - Unit 1 - C Programming Fundamentals

Uploaded by

ROHISIVAM
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1st Semester Anna University EEE- Reg 2021

Professional English – I
2nd Semester 3rd Semester
Matrices and Calculus
Probability and Complex
Professional English - II Functions
Engineering Physics
Statistics and Numerical Electromagnetic Fields
Engineering Chemistry Methods
Problem Solving and Physics for Electrical Digital Logic Circuits
Python Programming Engineering
Electron Devices and
Physics and Chemistry Basic Civil and Mechanical Circuits
Laboratory Engineering
Electrical Machines - I
Engineering Graphics
C Programming and Data
4th Semester Electric Circuit Analysis Structures
Environmental Sciences
and Sustainability 6th Semester
Transmission and 5th Semester
Distribution Protection and
Linear Integrated Power System Analysis Switchgear
Circuits
Power Electronics Power System
Measurements and Operation and Control
Instrumentation Control Systems
Open Elective – I
Microprocessor and
Microcontroller Professional Elective I
Professional Elective IV
Electrical Machines - II Professional Elective II
Professional Elective V
Professional Elective III
7th Semester Professional Elective VI
High Voltage Mandatory Course-I& Mandatory Course-
Engineering II& MC
Human Values and 8th Semester
Ethics
Elective –
Management Project Work /
Internship
Open Elective – II
Open Elective – III
Open Elective – IV
Professional Elective
VII Click on Clouds to navigate other department

https://www.poriyaan.in/
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BE- Electrical and Electronics Engineering


&
BE- Electronics and Communication Engineering

Anna University Regulation: 2021

CS3353 - C Programming and Data Structures

II Year/III Semester

Question Bank

Unit- I C PROGRAMMING FUNDAMENTALS

Prepared By,

Ms. S. Abarna, AP/CSE

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


UNIT I C PROGRAMMING FUNDAMENTALS

Data Types – Variables – Operations – Expressions and Statements – Conditional Statements


– Functions – Recursive Functions – Arrays – Single and Multi-Dimensional Arrays
UNIT-I / PART-A
1. What are the different data types available in “C”? (May 14)
There are four basic data types available in C.
 int
 float
 char
 double
2. What is an Operator, Operand and Keywords?
 Operator
 An operator is a symbol that specifies an operation to be performed on operands.
Example: *, +, -, / are called arithmetic operators.
 Operand
 The data items that operators act upon are called operands. Example: a+b; In this
statement a and b are called operands.
 Keywords
 Keywords are certain reserved words that have standard and pre-defined
meaning in C. These keywords can be used only for their intended purpose.
3. Define Constants in C. Mention the types.
The constants refer to fixed values that the program may not alter during its execution.
These fixed values are also called literals. Constants can be of any of the basic data types
like an integer constant, a floating constant, a character constant, or a string literal. There
are also enumeration constants as well. The constants are treated just like regular
variables except that their values cannot be modified after their definition.
4. What are Ternary operators or Conditional operators? (or) Give an Example for
Ternary operator. (Nov/Dec 14)
Ternary operators is a conditional operator with symbols ? and :
Syntax: test ? expression1 : expression2
 test-Any Boolean expression.
 expression1-An expression returned if test is true.
 expression2-An expression returned if test is false.
#include<stdio.h>//Header File
void main()//Main function of every C program
{
int a,b,c;
clrscr();
printf("Enter the values of a and b:");
scanf("%d%d" ,&a,&b
c = a>b ? a : b; //Ternary operator
printf("Larger number=%d" ,c);
}
Output
Enter the values of a and b:30 90
Larger number=90

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


5. What are the Bitwise operators and logical operators available in C ?
 Bitwise operators
 Bitwise AND, | - Bitwise OR, ~ - One„s Complement, >> - Right shift, << - Left
shift,
 ^ - Bitwise XOR are called bit field operators.
 Example: k=~j; where ~ take one„s complement of j and the result is stored in k.
 Logical operators
 The logical operators available in C are &&- Logical AND, || - Logical OR, ! -
Logical NOT
6. What is a Variable? Illustrate it with an example. (Nov/Dec 14)
 A variable is a data name used for storing a data value.
 Can be assigned different values at different times during program execution.
 Can be chosen by programmer in a meaningful way so as to reflect its function in the
program.
 Example: int i, num; //i, num are variables that can store integer values
7. What is the difference between Logical AND and Bitwise AND?
 Logical AND (&&): Only used in conjunction with two expressions, to test more
than one condition. If both the conditions are true the returns 1. If false then return 0.
 AND (&): Only used in Bitwise manipulation. It is a unary operator.
8. What is the importance of keywords in C. (May 15)
C programs are constructed from a set of reserved words which provide control and
from libraries which perform special functions. The basic instructions are built up using
a reserved set of words, such as main, for, if, while, default, double, extern, for, and int,
etc., C demands that they are used only for giving commands or making statements.
9. What is type casting?
Type casting is the process of converting the value of an expression to a particular data
type.
Example:
int x, y; c = (float) x/y; where a and y are defined as integers. Then the result of x/y is
converted into float.
10. What are various types of C operators? (Jan 14)
 Arithmetic Operators
 Increment and Decrement Operators
 Assignment Operators
 Relational Operators
 Logical Operators
 Conditional Operators
 Bitwise Operators
11. What are the main features and applications of C language? (Jan 11)
C is case sensitive language.
 Modularity: we can split the C program into no. of modules. It allows reusability of
modules.
 Middle level language: as a middle level language C combines both the advantages
of low level and high level languages. (arrays, pointers etc). Efficient Use of Pointers
 General purpose programming language: C can be used to implement any kind of
applications such as math‟s oriented, graphics, business oriented applications.
 Portability: we can compile or execute C program in any operating system
(unix,dos,windows).
 Powerful programming language: C is very efficient and powerful programming
language, it is best used for data structures and designing system software.
2

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


12. What is the difference between while loop and do…while loop? (or) Differentiate
Entry and Exit controlled constructs. (Jan 13)
While do-while
Its an entry controlled loop Its an exit controlled loop
In the while loop the condition is first In the do…while loop first the statement is
executed. If the condition is true then it executed and then the condition is
executes the body of the loop. When the checked. The do…while loop will execute
condition is false it comes of the loop at least one time even though the condition
is false at the very first time
Syntax: Syntax:
while(condition) do
{ {
//body of the loop //body of the loop
} } while(condition);
13. What is a Modulo Operator? What is the use of sizeof( ) operator?
 Modulo Operator
„%‟ is modulo operator. It gives the remainder of an integer division
o Example: a=17, b=6. Then c=%b gives 5.
 Sizeof( ) operator
 The sizeof ( ) operator gives the bytes occupied by a variable.
 No of bytes occupied varies from variable to variable depending upon its data
types.
Example:
int x,y;
printf(“%d”,sizeof(x));
Output: 2
14. Define with example integer and floating type of data in C language. (Jan 11)
 The int is used to define integer numbers. An integer occupies 2 bytes memory
space and its value range limited to -32768 to +32767 (that is, -215 to +215-1)
Example: int count=5
 The float is used to define floating point numbers. The float data type is used to
store fractional numbers (real numbers) with 6 digits of precision. Floating point
numbers are denoted by the keyword float.
Example: float miles = 4.5
15. What are the I/O Functions in C? (May 15, Jan 16)
 Formatted I/O Statements
 scanf(),printf()
 Unformatted I/O Statements:
 getchar(), putchar(), gets(), puts()
16. What is the difference between ++a and a++?
 ++a means do the increment before the operation (pre increment)
 a++ means do the increment after the operation (post increment)
Example:
a=5;
x=a++; /* assign x=5 but „a‟ value is incremented to 6*/
y=a; /*now y assigns y=6*/
x=++a; /*assigns x=7 and a value is incremented to 7*/
17. Construct an infinite loop using while?
while (1){ }
Here 1 is a non zero, value so the condition is always true. So it is an infinite loop.
3

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


18. What is a program?
A program is a set instruction written to carry out a particular task, so that computer can
perform some specified task. Example program to find sum of 2 numbers
#include<stdio.h>
void main()
{ int a, b, sum;
printf("\nEnter two no: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum : %d", sum);
}
Output : Enter two no: 5 6
Sum : 11
19. What is a global variable?
The global variable is a variable that is declared outside of all the functions. The global
variable is stored in memory, the default value is zero. Scope of this variable is available
in all the functions. The variable is live as long as the program terminates.
Example:
#include<stdio.h>
int a,b; //a,b are global variables
main()
{...}
20. What are the Escape Sequences present in “C”?
Escape Sequence Symbol Escape Sequence Name
\n New Line
\t Tab space
\r Carriage return
\f Form feed
21. Write the limitations of getchar( ) and scanf( ) functions for reading strings
 getchar( )-To read a single character from stdin, then getchar() is the appropriate.
 scanf( ) allows to read more than just a single character at a time. In scanf() when
there is a blank was typed, the scanf() assumes that it is an end
22. What is the difference between scanf() and gets() function?
In scanf() when there is a blank was typed, the scanf() assumes that it is an end.scanf()
accepts any datatype using appropriate format specifier. gets() assumes the enter key as
end. That is gets() gets a new line (\n) terminated string of characters from the keyboard
and replaces the „\n‟ with „\0‟. It accepts the input as only strings
23. Define Compilation, linking process? (or) What is meant by Linking process. (Jan 16)
 Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the
creation of an 'object' file. This step doesn't create anything the user can actually run.
Instead, the compiler merely produces the machine language instructions that
correspond to the source code file that was compiled.
 Linking refers to the creation of a single executable file from multiple object files. In
this step, it is common that the linker will complain about undefined functions
(commonly, main itself). During compilation, if the compiler could not find the
definition for a particular function, it would just assume that the function was
defined in another file. If this isn't the case, there's no way the compiler would know
it doesn't look at the contents of more than one file at a time. The linker, on the other
hand, may look at multiple files and try to find references for the functions that
weren't mentioned.
4

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


24. Write a C Program to find factorial of a given number using iteration.
#include<stdio.h>
int main()
{
int i=1,f=1,num;
printf("Enter a number: ");
scanf("%d",&num);
while(i<=num)
{
f=f*i;
i++;
}
printf("Factorial of %d is: %d",num,f);
return 0;
}
Output:
Enter a number: 5 Factorial of 5 is 120
25. Write a for loop statement to print numbers from 10 to 1. (Jan 14)
for( i=10;i>=1;i--)
printf(“\n%d”,i);
26. What is meant by storage class?
Every C variable has a storage class and a scope. The storage class determines the part of
memory where storage is allocated for an object and how long the storage allocation
continues to exist. It also determines the scope which specifies the part of the program
over which a variable name is visible, i.e. the variable is accessible by name. The
following are the storage classes which can be used in a C Program.
 auto ,register ,static and extern
27. Define Static Storage Class (Dec 14)
Storage class specifier static specifies that the declared object can be used both in local
scope and global scope. Static variable/object has a value throughout the execution of
the program and the object will be saved in main memory
Example: static int a;
28. Difference between Storage class and data type
Data type Storage class
It refers to the type of information It refers to the scope and lifetime of
the
represented by a variable variable within the program
Example: int, char, float Example: register, static, extern
29. What is enumeration constant?
An enumeration is a list of constant integer values, as in enum boolean {NO, YES}; The
first name in an enum has value 0, the next 1, and so on, unless explicit values are
specified. Names in different enumerations must be distinct. Values need not be
distinct
in the same enumeration
30. What is external storage class? (May 18)
A variable declared with the extern storage-class specifier is a reference to a variable
with the same name defined at the external level in any of the source files of the
program. A variable declared with the extern keyword is visible only in the block in
which it is declared

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


31. Difference between formatted and unformatted input statements.Give one example
for each. (May 19)
 Formatted input : The function scanf() is used for formatted input from standard
input and provides many of the conversion facilities of the function printf().
 Example: scanf(“ %c %d”,&name, &rollNo);
 Unformatted input : Unformatted I/O is the most basic form of I/O and it is simple,
efficient and compact.It is an input stream object in order to read a portion
of information in the form of bytes, without any translation. getchar() and
getch() functions will read a single character from the standard input.
Example: char ch; ch = getchar();
32. What is an array? Give an example (or) What is an array?Write the syntax for multi-
dimensional array. (Jan 13, 14) (May 15,18, 19)
 Array is data structure
 It stores objects/variables of same data types in contiguous memory locations
 Array elements can be accessed using index/subscript numbers
 Example: int arr[10];
The syntax for Multi-Dimensional array is
datatype arrayName [ arraySize 1 ][arraySize 2]..[arraySize N];
Example:
arr[10][20][15]
33. What are the main elements of an array declaration? (or) Give the general form
ofarray declaration. (Dec 06)
 Data type of array object
 Name of array object
 Size of the array
 Syntax: datatype arrayName [ arraySize ];
 Example: int arr[10];
34. Why is it necessary to give the size of an array in an array declaration?
When an array is declared, the compiler allocates a base address and reserves enough
space in the memory for all the elements of the array at compile time. Therefore size
must be specified in array declaration inorder to allocate the required space.
35. What are the classifications of array?
 ONE-Dimensional array. (Example: arr[10])
 TWO- Dimensional array. (Example: arr[10][20])
 Multi-Dimensional array. (Example: arr[10][20][15])
36. Write the features of array.
 Array contains data elements of same data type.
 Array stores fixed number of data elements.
 The elements in the array can be accessed by the index of the array.
 The elements are stored in contiguous location in an array
37. What is meant by Recursive function?
If a function calls itself again and again, then that function is called Recursive function

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

CS3353- C Programming and Data Structures


UNIT-I / PART-B
1. (i) Explain in detail about “C” declarations and variables. (Jan 11)
(ii) What are constants? Explain the various types of constants in C. (May 15)
2. Discuss about the various data types in “C”.
3. Explain about the various decision making statements in “C” language. (or) Write notes
on Branching Statements in C. (Jan 14,16 May 14,18)
4. Explain various operators in c with example? (or) Explain the different types of
operators used in C with necessary program. (Dec 14, May 15,18)
5. Explain briefly about the formatted and unformatted I/O function in C. (Jan 12)
6. Explain the different looping statement with example? (or) What is the purpose of
looping statement? Explain in detail the operations of various looping statement with
examples. (Jan 14,16, Dec 14, , May 15, 18, 19)
7. (i) Write a C program to check whether the given number is palindrome or not. (May 18)
(ii) Write a C program to sum of digits of an integer. (Jan 12, May 14)
8. Write a program to solve the Quadratic equation. (May 15)
9. Write a program to find whether a number is prime or not. (May 14)
10. Describe the structure of a C program using “Calculator program” example. (Jan 12)
11. Explain in detail about preprocessor directives with examples.
12. Explain the concept of storage classes with suitable example. (or) What are the Storage
classes available in C ? Demonstrate the working of each storage class.(May 14, 19, Jan
16)
13. Write a C program to find the sum of 10 non-negative numbers entered by the user.
(May 14)
14. Write a C program to find the largest among 3 numbers entered by the user. (May 19)
15. What is an array? Explain the characteristics and Classification of an array with
examples.
16. (i) Write a C program to find the largest and smallest element in an array.
(ii) Write a C program to search a given number in an array of elements.(Dec 14, May 15)
17. Write a program for multiplication of two matrices. (or) Write the C program to
multiply two matrices (two-dimensional array) which will be entered by a user. The
user will enter the order of a matrix and then its elements and similarly input the second
matrix. If the entered orders of two matrices are such that they can‟t be multiplied by
each other, then an error message is displayed on the screen. (Jan 16) (May 18)

CS3353_CPDS

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan
C Programming and Data Structures – Reg 2021 – CS3353
Unit I: C Programming Fundamentals : C Programming Fundamentals | Keywords, Variables and
Constants | Header Files | Data Types | Expressions using Operators | Input and Output Operations |
Decision Making and Conditional Statements | Functions | Recursive Functions | Arrays | Simple
Programs | Two Marks Questions with Answers

Unit II: C Programming – Advanced Features : C Programming – Advanced Features | Structures |


Union | Difference between Data Type, Structures and Unions | Enumerated Data Types | Pointers |
Strings and Pointers | Arrays and Functions | File Handling | Preprocessor Directives | Two Marks
Questions with Answers

Unit III: a. Linear Data Structures – List : Linear Data Structures - List | Introduction to Data Structure
| Abstract Data Types (ADTs) | List ADT | Array Based Implementation | Linked List | Difference between
Array and Linked Listed | Doubly Linked List | Circular Linked List | Applications of Linked Lists | Two
Marks Questions with Answers

Unit III: b. Linear Data Structures Stacks and Queues : Linear Data Structures Stacks and Queues |
Concept of Stack | Stack ADT | Implementation of Stack | Applications of Stack | Expression | Infix to
Postfix Conversion | Evaluation of Postfix Expressions | Concept of Queue | Queue ADT | Queue
Implementation | Priority Queues | Applications of Queue | Two Marks Questions with Answers

Unit IV: a. Non-Linear Data Structures – Trees : Non-Linear Data Structures – Trees | Trees | Binary
Trees | Representation of Binary Tree | Tree Traversal | Expression Trees | Binary Search Tree |
Programming Examples | Two Marks Questions with Answers

Unit IV: b. Hashing : Hashing | Basic Concept | Hash Functions | Properties of Good Hash Function |
Collision Handling | Applications of Hashing | Two Marks Questions with Answers

Unit V: Sorting and Searching Techniques : Sorting and Searching Techniques | Sorting | Insertion
Sort | Quick Sort | Heap Sort | Merge Sort | Searching | Two Marks Questions with Answers

3rd Semester (EEE dept)

HOME | EEE | ECE | MECH | CIVIL | CSE


1st Semester Anna University EEE- Reg 2021
Professional English – I
2nd Semester 3rd Semester
Matrices and Calculus
Probability and Complex
Professional English - II Functions
Engineering Physics
Statistics and Numerical Electromagnetic Fields
Engineering Chemistry Methods
Problem Solving and Physics for Electrical Digital Logic Circuits
Python Programming Engineering
Electron Devices and
Physics and Chemistry Basic Civil and Mechanical Circuits
Laboratory Engineering
Electrical Machines - I
Engineering Graphics
C Programming and Data
4th Semester Electric Circuit Analysis Structures
Environmental Sciences
and Sustainability 6th Semester
Transmission and 5th Semester
Distribution Protection and
Linear Integrated Power System Analysis Switchgear
Circuits
Power Electronics Power System
Measurements and Operation and Control
Instrumentation Control Systems
Open Elective – I
Microprocessor and
Microcontroller Professional Elective I
Professional Elective IV
Electrical Machines - II Professional Elective II
Professional Elective V
Professional Elective III
7th Semester Professional Elective VI
High Voltage Mandatory Course-I& Mandatory Course-
Engineering II& MC
Human Values and 8th Semester
Ethics
Elective –
Management Project Work /
Internship
Open Elective – II
Open Elective – III
Open Elective – IV
Professional Elective
VII Click on Clouds to navigate other department

https://www.poriyaan.in/

You might also like