#include <stdio.h>
#include <stdlib.h>
int main()
{
int* ptr;
int* ptr1;
int n; int i;int sum = 0;
n = 5;
printf("Number of elements: %d", n);
ptr = (int*)malloc(n * sizeof(int));
ptr1 = (int*)calloc(n, sizeof(int));
if (ptr == NULL || ptr1 == NULL)
{
printf("\nMemory not allocated.");
}
else
{
printf("\n\nMemory successfully allocated using malloc.");
for (i = 0; i < n; ++i)
{
ptr[i] = i + 1;
}
printf("\nThe elements of the first array (using malloc)
are: ");
for (i = 0; i < n; i++)
{
printf("%d ", ptr[i]);
}
printf("\nThe elements of the second array (using calloc")
are: ");
//showing that calloc introduces with 0
for (i = 0; i < n;i++)
{
printf("%d ", ptr1[i]);
}
//section 2
n = 12;
printf("\n\nnumber of elements in the first pointer : %d",
n);
//reallocation usage
int *ptr_new;
ptr_new =(int *)realloc(ptr,sizeof(int)*n ); //observe how
it works like calloc
printf("\nMemory successfully re-allocated using realloc.");
for (i = 5; i < 10;i++)
{
ptr_new[i] = i + 1;
}
printf("\nThe elements of the first array are: ");
for (i = 0; i < 10; i++)
{
printf("%d, ", ptr_new[i]);
}
//usage of free, literally frees up the memory assigned to the pointer
free(ptr_new);
printf("\n\nMalloc Memory successfully freed.");
free(ptr1);
printf("\n\nCalloc Memory successfully freed.");
}
return 0;
}
Introduction: SQL (Structured Query Language) is a cornerstone of data manipulation and querying in data science. SQL technical rounds are designed to assess a candidate’s ability to work with databases, retrieve, and manipulate data efficiently. This guide provides a comprehensive list of SQL interview questions segmented by experience level—beginner, intermediate, and experienced. For each level, you'll find key questions designed to evaluate the candidate’s proficiency in SQL and their ability to solve data-related problems. The difficulty increases as the experience level rises, and the final section will guide you on how to prepare effectively for these rounds. Beginner (0-2 Years of Experience) At this stage, candidates are expected to know the basics of SQL, common commands, and elementary data manipulation. What is SQL? Explain its importance in data science. Hint: Think about querying, relational databases, and data manipulation. What is the difference between WHERE
Comments
Post a Comment