0% found this document useful (0 votes)
69 views6 pages

CPDS Unit 1 QB

The document discusses C programming fundamentals including data types, variables, operators, conditional and looping statements, functions, arrays, and examples of programs to perform matrix operations, calculate student scores, and check number properties.

Uploaded by

kiruba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views6 pages

CPDS Unit 1 QB

The document discusses C programming fundamentals including data types, variables, operators, conditional and looping statements, functions, arrays, and examples of programs to perform matrix operations, calculate student scores, and check number properties.

Uploaded by

kiruba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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
 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 statement is
executed. executed and then the condition is
checked.

If the condition is true, then it executes the The do…while loop will execute at least
body of the loop. When the condition is one time even though the condition is false
false it comes of the loop. at the very first time.

9. 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)
10. What is a Function?
 A function is a block of code which only runs when it is called.
 It performs a specific task.
11. What is meant by Recursive function?
 If a function calls itself again and again, then that function is called Recursive
function.
 The syntax for recursive function is:
function recurse() {
// function code
recurse();
// function code
}
recurse();
12. Write short notes about main() function in ’C’ program.
Every C program must have main () function.
 All functions in C, has to end with ‘( )’ parenthesis.
 It is a starting point of all ‘C’ programs.
 The program execution starts from the opening brace ‘{‘ and ends with closing
brace ‘}’, within which executable part of the program exists.
13. Give the syntax for the ‘for’ loop statement
for (Initialize counter; Test condition; Increment / Decrement)
{
statements;
}
14. What is an Array?
 An array is defined as finite ordered collection of homogenous data, stored in
contiguous memory locations.
 finite means data range must be defined.
 ordered means data must be stored in continuous memory addresses.
 homogenous means data must be of similar data type.
 For example: if you want to store marks of 50 students, you can create an array for it.
 int marks[50];
15. What are the different types of arrays available in C.
 One-dimensional arrays
 Multidimensional arrays
16. Write short notes on One-dimensional arrays.
 A One-Dimensional Array in C programming is a special type of variable that can
store multiple values of only a single data type such as int, float, double, char etc.
 The syntax of declaring Two-dimensional arrays is:
 datatype array name [size]
 Example
For example, int a[5]
17. Write short notes on Two-dimensional arrays.
 A multi-dimensional array can be termed as an array of arrays that stores
homogeneous data in tabular form.
 The general form of declaring Two-dimensional arrays is:
 data_type array_name[x][y];
 Example
int x[10][20];
18. What are the key features in the C programming language?
 Portability: It is a platform-independent language.
 Modularity: Possibility to break down large programs into small modules.
 Flexibility: The possibility of a programmer to control the language.
 Speed: C comes with support for system programming and hence it compiles and
executes with high speed when compared with other high-level languages.
 Extensibility: Possibility to add new features by the programmer.
1.98 C Programming Fundamentals

19. What is a nested loop?


 A loop that runs within another loop is referred to as a nested loop. The first loop is
called the Outer Loop and the inside loop is called the Inner Loop. The inner loop
executes the number of times defined in an outer loop.
20. What are the modifiers available in C programming language?
 Short
 Long
 Signed
 Unsigned
 long long
21. What is the explanation for prototype function in C?
 Prototype function is a declaration of a function with the following information to the
compiler.
 Name of the function.
 The return type of the function.
 Parameters list of the function.
 Example
 int sum(int,int);
22. What do you mean by the Scope of the variable?
 Scope of the variable can be defined as the part of the code area where the variables
declared in the program can be accessed directly. In C, all identifiers are lexically (or
statically) scoped.
23. Can a C program be compiled or executed in the absence of a main()?
 The program will be compiled but will not be executed. To execute any C program,
main() is required.
24. What is the main difference between the Compiler and the Interpreter?

Interpreter Compiler
Translates program one statement at a time. Scans the entire program and translates it as a whole
into machine code.
Interpreters usually take less amount of time to Compilers usually take a large amount of time to
analyze the source code. analyze the source code.
However, the overall execution time is However, the overall execution time is comparatively
comparatively slower than compilers. faster than interpreters.
No Object Code is generated, hence are memory Generates Object Code which further requires
efficient. linking, hence requires more memory.
Programming languages like JavaScript, Python, Programming languages like C, C++, Java use
Ruby use interpreters. compilers.
PART-B
1. Illustrate the different conditional statements available in C with syntax and examples
2. Explain the looping statements with neat examples.
3. What is an Array? Explain Single and Multi-Dimensional arrays with neat examples.
4. Write a C program for Matrix Multiplication with a 3*3 matrix.
5. Create a C program for Matrix Addition.
6. Write a C program to calculate the total, average and grade for 50 Students.
7. Write a C program to calculate the factorial of a given number.
8. Write a C program to check whether a given number is odd or even.
9. Write a C program to check whether a given number is prime or not.
10. Write a C program to check whether a given number is a palindrome or not.
11. Write a C program to check whether a given number is a Armstrong number or not

You might also like