10 Marks
10 Marks
10 Marks
Characteristics of an Algorithm:
5. Effectiveness: The steps must be basic enough to be carried out, in principle, by a human or
machine.
1. Start
2. Input the first number a
3. Input the second number b
4. If a > b then
Output a (a is the largest)
5. Else
Output b (b is the largest)
6. End
Unit 2
Explain the structure of C program using example Describe the steps used in execution
of C program
Structure of a C Program:
1. Preprocessor Directives: Instructions like #include to include header files.
Example:
int main() {
printf("Hello, World!\n"); // Output statement
return 0;
}
MST 2
Unit 3
1. Function Declaration:
A function declaration informs the compiler about the function's name, return type, and
parameters, but it does not provide the actual implementation.
Example:
2. Function Definition:
A function definition provides the actual body of the function, including the logic that will be
executed when the function is called.
It contains the function's return type, name, parameters, and the code that defines what the
function does.
Example:
3. Function Call:
A function call is used to invoke a function and pass the required arguments to it. It tells the
program to execute the function's code.
Example:
What do you mean by pointers? Write a program to print the addressPointers in C/C++:
A pointer is a variable that stores the memory address of another variable. Instead of holding a
data value directly, it holds the address of a variable, allowing you to indirectly manipulate the
data stored at that address.
Pointers are especially useful for dynamic memory management, passing large structures or
arrays to functions, and more efficient code execution.
Syntax:
* (dereference operator) is used to access the value stored at the address the pointer is pointing
to.
Example Program:
The following program demonstrates how to use a pointer to print the address of a variable
along with its value:
#include <stdio.h>
int main() {
int num = 10; // Declare an integer variable
int *ptr; // Declare a pointer to integer
return 0;
}
Output:
Value of num: 10
Address of num: 0x7ffeedc1a6ec (Address may vary)