title-img


1D array in c

An array is a container object that holds a fixed number of values of a single type. To create an array in C, we can do int arr[n];. Here, arr, is a variable array which holds up to 10 integers. The above array is a static array that has memory allocated at compile time. A dynamic array can be created in C, using the malloc function and the memory is allocated on the heap at runtime. To create an integer array, arr of size 10, int *arr = (int*)malloc(n * sizeof(int)), where arr points to the bas

View Solution →

Array Reversal

Given an array, of size n, reverse it. Example: If array, arr=[1.2.3.4,5] after reversing it, the array should be, arr=[5,4,3,2,1] Input Format: The first line contains an integer, n, denoting the size of the array. The next line contains n space-separated integers denoting the elements of the array. Constraints: 1<=n<=1000 1<=arr[i]<=1000, where is the element of the array. Output Format: The output is handled by the code given in the editor, which would print the ar

View Solution →

Printing Tokens

Given a sentence, s, print each word of the sentence in a new line. Input Format: The first and only line contains a sentence, s. Constraints: 1<=len(s)<=1000 Output Format: Print each word of the sentence in a new line.

View Solution →

Digit Frequency

Given a string, s, consisting of alphabets and digits, find the frequency of each digit in the given string. Input Format: The first line contains a string, num which is the given number. Constraints: 1<=len(num)<=1000 All the elements of num are made of english alphabets and digits. Output Format: Print ten space-separated integers in a single line denoting the frequency of each digit from 0 to 9.

View Solution →

Dynamic Array in C

Snow Howler is the librarian at the central library of the city of HuskyLand. He must handle requests which come in the following forms: 1 x y : Insert a book with y pages at the end of the xth shelf. 2 x y : Print the number of pages in the yth book on the xth shelf. 3 x : Print the number of books on the xth shelf. Snow Howler has got an assistant, Oshie, provided by the Department of Education. Although inexperienced, Oshie can handle all of the queries of types 2 and 3. Help

View Solution →