Remove Nested Records from Tuple in Python

AmitDiwan
Updated on 11-Mar-2021 09:05:14

351 Views

When it is required to remove nested record/tuples from a tuple of tuple, a simple loop and the 'isinstance' method and the enumerate method can be used.The enumerate method adds a counter to the given iterable, and returns it. The 'isinstance' method checks to see if a given parameter belong to a specific data type or not.Below is a demonstration of the same −ExampleLive Demotuple_1 = (11, 23, (41, 25, 22), 19) print("The tuple is : ") print(tuple_1) my_result = tuple() for count, elem in enumerate(tuple_1):    if not isinstance(elem, tuple):       my_result = my_result + ... Read More

Importance of C Language and Its General Structure

Bhanu Priya
Updated on 11-Mar-2021 08:36:53

7K+ Views

C programming is a general-purpose, procedural, imperative computer programming language.Importance of C LanguageC is called as a robust language, which has so many built-in functions and operations, which can be used to write any complex program.Generally, we use to call C as a middle level language. Because, the ‘C’ compiler combines the capabilities of an assembly language with the features of a high-level language. Therefore, it is best for writing both system software and business packages.‘C’ Programs are efficient and fast.C is highly portable, that is, ‘C’ programs written on one computer can be run on another with little (or) ... Read More

Format of C Language

Bhanu Priya
Updated on 11-Mar-2021 08:35:46

2K+ Views

C programming is a general-purpose, procedural, imperative computer programming language. In C language, we see thatStatements are terminated with semicolons.C is case sensitiveIndentation is ignored by the compiler.Strings are placed in double quotes.Library functions are lowercase.Newlines are handled via Format of CThe format of C programming language is explained below −SemicolonsSemicolons are very important in C.It tells the compiler, where one statement ends and the next statement begins.If we fail to place the semicolon after each statement, you will get compilation errors.Case SensitivityC is a case sensitive language. Although, int compiles, "Int”, "INT” or any other variation will not be ... Read More

Check If Value Is Palindrome Using C Language

Bhanu Priya
Updated on 11-Mar-2021 08:28:05

586 Views

A palindrome is nothing but any word, number, sentence, or other sequence of characters that reads the same backward as forward.In this programming, we are trying to enter a number from console, and assign that number to temp variable.If number is greater than zero, apply the logic given below −while(n>0){    r=n%10;    sum=(sum*10)+r;    n=n/10; }If temp=sum, then the given number is a palindrome. Otherwise, it is not a palindrome.ExampleFollowing is the C program for verification of a value being palindrome −#include #include void main(){    int n, r, sum=0, temp;    printf("Enter a number: ");    scanf("%d", &n); ... Read More

Include Header File Twice in a C Program

Bhanu Priya
Updated on 11-Mar-2021 08:16:08

1K+ Views

C header files include some predefined functions. For example, printf() and scanf() functions are defined in the stdio.h header file.Each header files in C contains different predefined functions to make programs simple to understand.When a header file is included two times in a C program, the second one gets ignored. In actual, the #, called the include, preceding a header file ensures that it is included only once during the compilation process.Example 1Following is the C program for computing an average of three numbers − Live Demo#include #include //header file included twice ,ignored by compiler main(){    int a, b, c, ... Read More

Different Searching Techniques in C Language

Bhanu Priya
Updated on 11-Mar-2021 07:59:07

10K+ Views

Searching technique refers to finding a key element among the list of elements.If the given element is present in the list, then the searching process is said to be successful.If the given element is not present in the list, then the searching process is said to be unsuccessful.C language provides two types of searching techniques. They are as follows −Linear searchBinary searchLinear SearchSearching for the key element is done in a linear fashion.It is the simplest searching technique.It does not expect the list to be sorted.Limitation − It consumes more time and reduce the power of system.Input (i/p)Unsorted list of ... Read More

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

255 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

298 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

Advertisements