Unit 1 CS3353 - C Programming and Data Structures
Unit 1 CS3353 - C Programming and Data Structures
PART-A
1. List down the Primary Data Types in C
Integer – We use these for storing various whole numbers, such as 5, 8, 67,
2390, etc.
Character – It refers to all ASCII character sets as well as the single alphabets,
such as ‘x’, ‘Y’, etc.
Double – These include all large types of numeric values that do not come
under either floating-point data type or integer data type.
Floating-point – These refer to all the real number values or decimal points,
such as 40.1, 820.673, 5.9, etc.
Void – This term refers to no values at all. We mostly use this data type when
defining the functions in a program.
2. What is Variable?
Variables are containers for storing data values.
Its value can be changed, and it can be reused many times.
Syntax for creating variables
type variableName = value;
Example: int a = 5;
3. What is Operator?
An operator is a special symbol that tells the compiler to perform specific
mathematical or logical operations.
Operators in programming languages are taken from mathematics.
C language supports a rich set of built-in operators.
4. List the types of operators supported in C
Arithmetic operators
Relational operators
Logical operators
Bitwise operators
C Programming and Data Structures 1.95
Assignment operators
Type Information Operators(Special operators)
5. What is Ternary operators or Conditional operators?
Ternary operators is a conditional operator with symbols? and :
Syntax: variable = exp1 ? exp2 : exp3
If the exp1 is true variable takes value of exp2. If the exp2 is false, variable
takes the value of exp3.
6. What is an Operator and Operand?
An operator is a symbol that specifies an operation to be performed on
operands.
Example: *, +, -, / are called arithmetic operators.
The data items that operators act upon are called operands.
7. 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.
8. What is the difference between while loop and do while loop?
while do while
In the while loop the condition is first In the do…while loop first the
executed. statement is executed and then the
condition is checked.
If the condition is true, then it executes The do…while loop will execute at
the body of the loop. When the least one time even though the
condition is false it comes of the loop. condition is false at the very first time.
Interpreters usually take less amount of Compilers usually take a large amount
time to analyze the source code. of time to analyze the source code.
However, the overall execution time is However, the overall execution time is
comparatively slower than compilers. comparatively faster than interpreters.
No Object Code is generated, hence are Generates Object Code which
memory efficient. further requires linking, hence
requires more memory.
Programming languages like Programming languages like C, C++,
JavaScript, Python, Ruby use Java use compilers.
interpreters.
PART-B
1. Explain the different types of operators with neat examples.
2. Illustrate the different conditional statements available in C with syntax and examples
3. Explain the looping statements with neat examples.
4. What is an Array? Explain Single and Multi-Dimensional arrays with neat examples.
5. Write a C program for Matrix Multiplication with a 3*3 matrix.
6. Create a C program for Matrix Addition.
7. Write a C program to calculate the total, average and grade for 50 Students.
8. Write a C program to calculate the factorial of a given number.
9. Write a C program to check whether a given number is odd or even.
10. Write a C program to check whether a given number is prime or not.
11. Write a C program to check whether a given number is a palindrome or not.
12. Write a C program to check whether a given number is a Armstrong number or not.