Professional Documents
Culture Documents
Pps 1mark Questions With Key
Pps 1mark Questions With Key
Ans: printf() and scanf() functions are inbuilt library functions in C/predefined functions which
are available in which are available in “ stdio.h” header file.
printf() function is used to print the “character, string, float, integer, octal and hexadecimal
values” onto the output screen.
scanf() function is used to read character, string, numeric data from keyboard
Example 1: printf("You entered: %d", num); - formatted printf() function where %d is format
specifier
NOTE : write few keywords need not to memorize all 32 keywords as the question is for 1mark
only
3. Define a Variable?
Ans: Variable is the name of a memory location that we use for storing data. We can change the
value of a variable in C language and we can also reuse it multiple times.
Syntax for variable Declaration:
DataType VariableList;
Ans: Enumeration or an enum in C is a user-defined data type that consists of a set of named
integer constants. Enums are used to represent a group of related values, such as the days of the
week, the months of the year, or the colors of the rainbow.
example:
enum Color {
RED,
GREEN,
BLUE
};
9. What is a String?
Ans: C Strings are nothing but array of characters ended with null character (‘\0’).Strings are
always enclosed by double quotes. Whereas, character is enclosed by single quotes in C.
Example:
char string[20] = { ‘H’ , ‘e’ , ‘l’ , ‘l’ , ‘o’ , ‘\0’};
(or)
char string[20] = “Hello”;
(or)
char string [] = “Hello”;
Example:
struct Student {
char name[20];
int age;
float grade;
};
Calloc
is same as malloc but it initialize 0 value.calloc () for allocating multipleblocks of memory.
Syntax:
*ptr-variable=(type-casting*)calloc(n,sizeof(DataType))
Example:
*ptr=(int*)calloc(5,sizeof(int));
malloc(): Allocates a block of memory of the specified size and returns a pointer to the allocated
memory.
free(): Frees the memory allocated by malloc().
calloc(): Allocates an array of the specified size and initializes each element to zero.
realloc(): Changes the size of an existing memory block.
atoi(): Converts a string to an integer.
atof(): Converts a string to a floating-point number.
rand(): Generates a random number.
srand(): Initializes the random number generator.
exit(): Terminates the program.
system(): Executes a system command.
abort(): Terminates the program abnormally.
Time complexity: Linear search has a time complexity of O(n), which means that the time it
takes to search for an element increases linearly as the size of the dataset increases.
Efficiency: Linear search is time consuming and not very efficient because it compares each
element one by one.
Large datasets: Linear search is not suitable for large arrays.
5. On each iteration of j:
If arr[i] > arr[i] then we swap the number in order to sort the array in ascending order.
Else continue
In this manner, the array will be sorted in ascending order will the lowest elem