0% found this document useful (0 votes)
12 views7 pages

Oral Questions With Short Ans

The document provides a comprehensive overview of fundamental concepts in algorithms and the C programming language, including definitions of algorithms, control structures, data types, and functions. It covers essential topics such as pointers, arrays, conditional statements, and user-defined functions, along with examples and syntax. The document serves as a guide for understanding programming principles and C language constructs.

Uploaded by

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

Oral Questions With Short Ans

The document provides a comprehensive overview of fundamental concepts in algorithms and the C programming language, including definitions of algorithms, control structures, data types, and functions. It covers essential topics such as pointers, arrays, conditional statements, and user-defined functions, along with examples and syntax. The document serves as a guide for understanding programming principles and C language constructs.

Uploaded by

haribiradar9226
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

1 Fundamentals of
Algorithms
Q1. What is an algorithm? Q10. What are tokens?
A: An algorithm is a step-by-step procedure A: Smallest units in C (keywords,
to solve a problem. identifiers, constants, operators).
Q2. What are the characteristics of an Q11. What are keywords?
algorithm? A: Reserved words with special meaning
A: Input, Output, Definiteness, Finiteness, (e.g., int, if, return).
Effectiveness.
Q12. What is an identifier?
Q3. What is an assignment statement? A: Name given to variables or functions.
A: It assigns a value to a variable using =
operator (e.g., a = 5;). Q13. What are constants?
A: Fixed values that do not change.
Q4. Name basic control structures.
A: Sequence, Selection (if, switch), Iteration Q14. Types of constants?
(loops). A: Numeric, Character, String.

1.2 Introduction to C Q15. What is a variable?


A: A named memory location to store data.
Q5. What is the structure of a C
program? Q16. What are data types in C?
A: Documentation → Header files → Global A: int, float, char, double, etc.
declarations → main() → Functions.
Q17. How do you declare a variable?
Q6. What is a header file? A: Example: int a;
A: A file containing function declarations
(e.g., stdio.h). Q18. What is type conversion?
A: Converting one data type into another.
Q7. What is the role of main() function?
A: It is the entry point of a C program. 1.4 Input and Output
Q8. What is #include?
Functions
A: A preprocessor directive to include
Q19. What is printf()?
header files.
A: Used to display output.

1.3 Fundamental Constructs of Q20. What is scanf()?


C A: Used to take input from user.

Q9. What is a character set in C? Q21. What is a format specifier?


A: Letters, digits, and symbols used to form A: Defines type of data (e.g., %d, %f, %c).
programs.
Q22. Give example of printf(). Q3. What is an if statement?
A: printf("Hello"); A: It executes a block of code if a condition
is true.
Q23. Why is & used in scanf()?
A: To get the address of variable. Q4. What is an if-else statement?
A: Executes one block if condition is true,
1.5 Assignments and otherwise another block.
Expressions Q5. What is nested if-else?
A: An if-else inside another if-else.
Q24. What is an expression?
A: Combination of variables, constants, and
Q6. What is an if-else ladder?
operators.
A: Multiple conditions checked one after
another.
Q25. What are arithmetic operators?
A: +, -, *, /, %
Q7. What is a switch statement?
A: Multi-way selection statement based on
Q26. What are shift operators?
value of a variable.
A: << (left shift), >> (right shift)
Q8. What type of values are used in
Q27. What are bitwise operators?
switch?
A: &, |, ^, ~
A: Integer or character constants.
Q28. What is sizeof operator?
Q9. What is the use of case in switch?
A: Returns size of a variable/type in bytes.
A: Defines different possible values.
Q29. What is a simple assignment
Q10. What is default in switch?
statement?
A: Assigning value using = (e.g., x = 10;) A: Executes when no case matches.

Q30. Difference between = and = =? Q11. Why is break used in switch?


A: = assigns value; = = compares values. A: To stop execution of further cases.

2.1 Conditional Statements 2.2 Looping Statements

Q1. What are relational operators? Q12. What is a loop?


A: Operators used to compare values (<, >, A: A structure used to repeat a block of
code.
<=, >=, ==, !=).

Q13. What is a while loop?


Q2. What are logical operators?
A: Operators used to combine conditions A: Entry-controlled loop; condition checked
before execution.
(&&, ||, !).
Q14. What is a do-while loop?
A: Exit-controlled loop; executes at least
once.
Q15. What is a for loop? 3.1 Arrays Basics
A: Loop with initialization, condition, and
increment/decrement.
Q1. What is an array?
A: A collection of elements of the same data
Q16. Which loop executes at least once?
type stored in contiguous memory.
A: do-while loop.
Q2. What are characteristics of an array?
Q17. Which loop is best when number of
A: Fixed size, same data type, stored in
iterations is known?
continuous memory.
A: for loop.
Q3. What is a one-dimensional array?
Q18. Syntax of for loop?
A: Array with a single index (e.g., int
A: for(init; condition; update)
a[5];).

Q19. Difference between while and for?


Q4. What is a two-dimensional array?
A: for is compact; while is used when
A: Array with rows and columns (e.g., int
iterations are unknown.
a[3][3];).

Q5. What is a multi-dimensional array?


2.3 Branching Statements A: Array with more than two dimensions.

Q20. What is a goto statement?


A: Transfers control to a labeled statement. 3.2 Declaration and
Q21. Why is goto not recommended? Initialization
A: Makes code complex and hard to
understand. Q6. How do you declare an array?
A: int a[10];
Q22. What is break statement?
A: Terminates loop or switch immediately. Q7. How do you initialize an array?
A: int a[3] = {1, 2, 3};
Q23. What is continue statement?
A: Skips current iteration and continues next Q8. Can we initialize array without size?
iteration. A: Yes, compiler calculates size (e.g., int
a[] = {1,2,3};).
Q24. Difference between break and
continue? Q9. Default value of array elements?
A: break exits loop; continue skips one A: Garbage values (if not initialized).
iteration.

Q25. Can break be used in loops? 3.3 Operations on Arrays


A: Yes, to exit the loop early.
Q10. What are basic operations on
Q26. Can continue be used in switch? arrays?
A: No, only used in loops.
A: Traversal, insertion, deletion, searching, Q22. Give syntax of structure.
sorting. A:

Q11. What is traversal? struct student {


A: Accessing each element of array. int id;
char name[20];
};
Q12. What is searching?
A: Finding an element in array. Q23. How to declare structure variable?
A: struct student s1;
Q13. What is sorting?
A: Arranging elements in order. Q24. How to access structure members?
A: Using dot operator ([Link]).
3.4 Strings and Character I/O Q25. What is array of structures?
A: Collection of structure variables (e.g.,
Q14. What is a string in C? struct student s[10];).
A: Array of characters ending with '\0'
(null character). Q26. What are features of structures?
A: Store different data types, easy grouping
Q15. How do you declare a string? of data.
A: char str[10];

Q16. What is '\0'? 3.6 typedef and Enumeration


A: Null character indicating end of string.
Q27. What is typedef?
Q17. Name string input functions. A: Used to create new name for existing
A: scanf(), gets() (deprecated), fgets(). data type.

Q18. Name string output functions. Q28. Example of typedef?


A: printf(), puts(). A: typedef int num;
Q19. What are string handling functions? Q29. What is an enumeration (enum)?
A: strlen(), strcpy(), strcat(), A: User-defined data type with named
strcmp(). integer constants.

Q20. What is strlen()? Q30. Example of enum?


A: Returns length of string. A:

enum day {Mon, Tue, Wed};


3.5 Structures
Q31. What is default value of enum
Q21. What is a structure? constants?
A: User-defined data type that groups A: Starts from 0 by default.
different data types.
4.1 Concept and Need of 4.3 User Defined Functions
Functions
Q11. What is a user-defined function?
A: Function created by programmer.
Q1. What is a function in C?
A: A block of code that performs a specific
Q12. What is function declaration?
task.
A: Tells compiler about function
(prototype).
Q2. Why are functions used?
A: To reduce code repetition and improve
Q13. What is function definition?
modularity.
A: Actual body of function.
Q3. What are advantages of functions?
Q14. What is function call?
A: Code reuse, readability, easier
A: Invoking a function to execute.
debugging.
Q15. What is scope of a variable?
A: Region where variable is accessible.
4.2 Library Functions
Q16. What is local variable?
Q4. What are library functions? A: Declared inside function; used only there.
A: Predefined functions provided by C.
Q17. What is global variable?
Q5. Give examples of math functions. A: Declared outside all functions; accessible
A: sqrt(), pow(), sin(), cos(). everywhere.

Q6. Give examples of string functions.


A: strlen(), strcpy(), strcmp(), 4.4 Function Parameters
strcat().
Q18. What is parameter passing?
Q7. What is getchar()? A: Passing values to functions.
A: Reads a single character from input.
Q19. What is call by value?
Q8. What is putchar()? A: Copy of value is passed.
A: Displays a single character.
Q20. What is call by reference?
Q9. What is malloc()? A: Address of variable is passed.
A: Allocates memory dynamically.
Q21. Difference between call by value and
Q10. What is calloc()? reference?
A: Allocates and initializes memory to zero. A: Value doesn’t change in call by value;
changes in reference.

Q22. What is return value?


A: Value returned by function.
Q23. What is return type? Q6. How to initialize a pointer?
A: Data type of returned value. A: p = &a;

Q24. How to declare return type? Q7. How to access value using pointer?
A: Before function name (e.g., int sum()). A: Using *p.

Q25. What is return statement?


A: Ends function and sends value back. 5.2 Pointer Arithmetic
Q8. What is pointer arithmetic?
4.5 Recursive Functions A: Operations on pointers like
increment/decrement.
Q26. What is recursion?
A: Function calling itself. Q9. What happens when pointer is
incremented?
Q27. What is base condition? A: It moves to next memory location of its
A: Condition to stop recursion. type.

Q28. Give example of recursion. Q10. Can we add two pointers?


A: Factorial calculation. A: No.

Q29. What happens without base Q11. Can we subtract two pointers?
condition? A: Yes (gives distance between them).
A: Infinite recursion (program crash).

5.4 Pointer and Strings


5.1 Introduction to Pointers
Q16. How are strings related to pointers?
Q1. What is a pointer? A: Strings are arrays of characters accessed
A: A variable that stores the address of using pointers.
another variable.
Q17. Example of string pointer?
Q2. Why are pointers used? A: char *str = "Hello";
A: For dynamic memory, efficient data
handling, and call by reference. Q18. How to access string characters
using pointer?
Q3. What is * operator? A: *(str + i)
A: Used to declare pointer and dereference
(access value).
5.5 Function Handling Using
Q4. What is & operator?
A: Returns address of a variable. Pointers

Q5. How do you declare a pointer? Q19. How are pointers used in functions?
A: int *p; A: For call by reference.
Q20. Why use pointers in functions? struct student s1;
A: To modify original variables. struct student *p;

Q21. Example of pointer in function?  s1 → structure variable


A: Passing address: func(&a);  p → pointer to structure

5.6 Pointer to Structure 3. Initialization


p = &s1;
Q22. What is pointer to structure? // p now stores the address
A: Pointer storing address of structure of s1.
variable.

Q23. How to declare pointer to structure? 4. Accessing Structure


A: struct student *p; Members
Q24. How to access members using Using Arrow Operator (->) ⭐ (Most
pointer? Important)
A: Using -> operator (e.g., p->id). p->id = 101;
Q25. Difference between . and ->?
A: . for structure variable, -> for pointer. 5. Example Program
#include<stdio.h>
#include<conio.h>
struct student
Pointer to Structure in C( NOTES) {
int id;
char name[20];
1. Definition };

A pointer to structure is a pointer variable void main() {


that stores the address of a structure struct student s1 = {101,
variable. "Rahul"};
struct student *p;
Instead of accessing structure members
directly, we use a pointer. p = &s1;
printf("ID = %d\n",p->id);
printf("Name=%s\n”,
2. Declaration p->name);
struct student { getch();
int id; }
char name[20];
};

You might also like