Concept of Sorting in C Language

Bhanu Priya
Updated on 11-Mar-2021 07:51:40

5K+ Views

ProblemWhy sorting makes searching easier in C language? How can you judge the sorting efficiency in C?SolutionSorting is the process of arranging elements either in ascending (or) descending order.The term sorting came into existence when humans realized the importance of searching quickly.There are different things in life that we need to search for, particular record in database, roll numbers in a list, a number in a telephone directory, a specific page in a book etc.If the data was kept in an unordered and unsorted form, it becomes difficult to search a particular thing. But fortunately, the concept of sorting came ... Read More

Print Content into Files Using C Language

Bhanu Priya
Updated on 11-Mar-2021 07:51:00

260 Views

We can write a program in C for printing some content in to the file and print the following −Number of characters entered into the file.Reverse the characters entered into the file.First, try to store number of characters into the file by opening the file in write mode.For entering data into file, we use the logic as mentioned below −while ((ch = getchar( ))!=EOF) {//after enter data press cntrl+Z to terminate    fputc(ch, fp); }With the help of ftell, rewind, fseek functions, we can reverse the content that we already entered into the file.ExampleGiven below is a C program for ... Read More

Random Accessing Files in C Language

Bhanu Priya
Updated on 11-Mar-2021 07:20:51

11K+ Views

Random accessing of files in C language can be done with the help of the following functions −ftell ( )rewind ( )fseek ( )ftell ( )It returns the current position of the file ptr.The syntax is as follows −int n = ftell (file pointer)For example, FILE *fp; int n; _____ _____ _____ n = ftell (fp);Note − ftell ( ) is used for counting the number of characters which are entered into a file.rewind ( )It makes file ptr move to beginning of the file.The syntax is as follows −rewind (file pointer);For example, FILE *fp;    -----    -----   ... Read More

Display Relation Between Pointer to Pointer in C

Bhanu Priya
Updated on 11-Mar-2021 07:10:58

305 Views

In C programming language, pointer to pointer or double pointer is a variable that holds the address of another pointer.DeclarationGiven below is the declaration for pointer to pointer −datatype ** pointer_name;For example, int **p;Here, p is a pointer to pointer.Initialization‘&’ is used for initialization.For example, int a = 10; int *p; int **q; p = &a;AccessingIndirection operator (*) is used for accessingSample programFollowing is the C program for double pointer − Live Demo#include main ( ){    int a = 10;    int *p;    int **q;    p = &a;    q = &p;    printf("a =%d ", a);   ... Read More

Copy Contents of One File to Another in C

Bhanu Priya
Updated on 11-Mar-2021 07:09:19

23K+ Views

File is a collection of records (or) is a place on hard disk, where data is stored permanently. By using C commands, we can access the files in different ways.Operations on filesThe operations that can be carried out on files in C language are as follows −Naming the file.Opening the file.Reading from the file.Writing into the file.Closing the file.SyntaxThe syntax for opening and naming file is as follows −FILE *File pointer;For example, FILE * fptr;File pointer = fopen ("File name”, "mode”);For example, fptr = fopen ("sample.txt”, "r”);FILE *fp; fp = fopen ("sample.txt”, "w”);The syntax for reading from file is as ... Read More

High-Level I/O Functions in C Language

Bhanu Priya
Updated on 11-Mar-2021 07:03:50

5K+ Views

I/O refers to the input - output functions in C language.High level I/OThese are easily understood by human beingsThe advantage is portability.Low level I/OThese are easily understood by computer.The advantage is that execution time is less.The disadvantage is that Non portability.High level I/O FunctionsThe high level input - output (I/O) functions are explained below −FunctionDescriptionfprintf ( )write data into a filefscanf ( )read data from a fileputc ( )/ fputc()write a character into a filegetc ( ) /fgetc()read a character from a fileputw ( )write a number into a filegetw ( )read number from a filefputs ( )write a string ... Read More

Meaning of Line 'Yug Shahstra Yojan Par Bhanu' from Hanuman Chalisa

Knowledge base
Updated on 10-Mar-2021 18:57:59

44K+ Views

Lord Hanuman is the great central characters  of the Indian epic Ramayana. Hanuman is well-known for his strength and he is immune to all sorts of weapons. He has got extreme speed (manojavam, marutha tulya vegam) effulgence, wisdom, no fear of death (Chiranjeevi), has won over the senses that lure. He has the knowledge of Eight Siddhis and Nine devotions. Even the world’s dangerous weapon Brahmastra can never harm him. He is the most powerful yet very obedient devotee of Shri Rama.The accurate prediction of distance from Earth to Sun:It was written in Hanuman Chalisa, “Yug Sahasra Yojana Par Bhanu, ... Read More

Form Cumulative Sum List in Python

pawandeep
Updated on 10-Mar-2021 14:26:20

3K+ Views

The cumulative sum till ith element refers to the total sum from 0th to ith element.The program statement is to form a new list from a given list. The ith element in the new list will be the cumulative sum from 0 to ith element in the given list.For example, Input[10, 20, 30, 40, 50]Output[10, 30, 60, 100, 150]Input[1, 2, 3, 4, 5]Output[1, 3, 6, 10, 15]Following is a program to form a cumulative sum list using the input list −The input list is passed to the function cumSum() which returns the cumulative sum list.We declare an empty list cum_list ... Read More

Round Off a Number in Python

pawandeep
Updated on 10-Mar-2021 14:18:23

867 Views

Python has an inbuilt round() function to round off a number.The round() method in Python takes two parameters −The first one is the number to be rounded off.The second one specifies the number of digits to which the number must be rounded off.Here, the second parameter is optional.If second parameter is not specified, then the round() method returns the integer using floor() and ceil().It will look for the digits after the decimal.If those are less than 5, it returns the floor() of the number passed.Whereas if the digits after decimal are greater than 5, it returns the ceil() of the ... Read More

Print Pattern in Python

pawandeep
Updated on 10-Mar-2021 14:15:23

2K+ Views

Patterns in Python can be printed using nested for loops. The outer loop is used to iterate through the number of rows whereas the inner loop is used to handle the number of columns. The print statement is modified to form various patterns according to the requirement.The patterns can be star patterns, number patterns, alphabet patterns. The patterns can be of different shapes, triangle, pyramids, etc.ExampleAll these patterns can be printed with the help of for loops with modified print statements which forms these different patterns.The basic idea between the printing of these patterns is the same with slight differences.We ... Read More

Advertisements