- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1401 Articles for C
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
4K+ Views
ProblemFind out if a given number can be expressed as sum of two prime numbers or not.Given a positive integer N, we need to check if the number N can be represented as a sum of two prime numbers.SolutionConsider an example given below −20 can be expressed as sum of two prime numbers 3 and 17, 13 and 7.20= 3+720= 13+7AlgorithmRefer an algorithm given below for expressing a given number as a sum of two prime numbers.Step 1 − Input the number to be checked at run time.Step 2 − Repeat from i = 2 to (num/2).Step 3 − Check ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
4K+ Views
We can apply the software development method to solve the linear equation of one variable in C programming language.RequirementThe equation should be in the form of ax+b=0a and b are inputs, we need to find the value of xAnalysisHere, An input is the a, b values.An output is the x value.AlgorithmRefer an algorithm given below to find solution of linear equation.Step 1. Start Step 2. Read a, b values Step 3. Call function Jump to step 5 Step 4. Print result Step 5: i. if(a == 0)Print value of c cannot be predictedElseCompute c=-b/aReturn cStep 6: StopProgramFollowing is the C ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
2K+ Views
Linked lists use dynamic memory allocation i.e. they grow and shrink accordingly. They are defined as a collection of nodes. Here, nodes have two parts, which are data and link. The representation of data, link and linked lists is given below −Types of Linked ListsLinked lists have four types, which are as follows −Single / Singly linked listsDouble / Doubly linked listsCircular single linked listCircular double linked listThe logic we used to find the length of linked list by using recursion method is −int length(node *temp){ if(temp==NULL) return l; else{ l=l+1; ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
2K+ Views
C programming language provides two types of searching techniques. They are as follows − Linear search Binary search Binary Search This method can be applied only to sorted list. The given list is divided into two equal parts. The given key is compared with the middle element of the list. Here, three situations may occur, which are as follows − If the middle element matches the key, then the search will end successfully here ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
2K+ Views
ProblemWrite a program to replace all zeros (0's) with 1 in a given integer.Given an integer as an input, all the 0's in the number has to be replaced with 1.SolutionConsider an example given below −Here, the input is 102410 and the output is 112411.AlgorithmRefer an algorithm given below to replace all the 0’s to 1 in an integer.Step 1 − Input the integer from the user.Step 2 − Traverse the integer digit by digit.Step 3 − If a '0' is encountered, replace it by '1'.Step 4 − Print the integer.ExampleGiven below is the C program to replace all 0's ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
4K+ Views
A local static variable is a variable, whose lifetime doesn’t stop with a function call where it is declared. It extends until the lifetime of a complete program. All function calls share the same copy of local static variables.These variables are used to count the number of times a function is called. The default value of static variable is 0. Whereas, normal local scope specifies that the variables defined within the block are visible only in that block and are invisible outside the block.The global variables which are outside the block are visible up to the end of the program.ExampleFollowing ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
593 Views
In C programming language, the most common use of structure is an array of structures.To declare an array of structures, first the structure must be defined and then, an array variable of that type has to be defined.For example,struct book b[10];//10 elements in an array of structures of type ‘book’ExampleFollowing is the C program for the array of structures − Live Demostruct marks{ int sub1; int sub2; int sub3; int total; }; main(){ int i; struct marks student[3] = {{20,17,11,10}, {175,23,169,10}, {27,56,27,01}}; struct marks total; for(i = 0; i
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
7K+ Views
In C programming language, a structure is a collection of different datatype variables, which are grouped together under a single name.Declaration and initialization of structuresThe general form of a structure declaration is as follows −datatype member1; struct tagname{ datatype member2; datatype member n; };Here, struct is a keyword.tagname specifies the name of structure.member1, member2 specifies the data items that make up structure.For example, struct book{ int pages; char author [30]; float price; };Structure variablesThere are three methods of declaring structure variables, which are as follows −First methodstruct book{ int pages; char author[30]; ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
988 Views
C programming language provides two types of searching techniques. They are as follows − Linear search Binary search Linear Search Searching 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 Unsorted list of elements, key. Output Success – If key is found. Unsuccessful – Otherwise. Example 1 Following ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
1K+ Views
Queue overflow and Queue under flow can be avoided by using linked list.Operations carried out under queue with the help of linked lists in C programming language are as follows −InsertDeleteInsertionThe syntax is as follows −Syntax&item : Newnode = (node*) mallac (sizeof (node)); newnode ->data = item; newnode ->link = NULL; if ((front = = NULL) || (rear = = NULL)){ front= newnode; rear = newnode; }else{ Rear->link = newnode; rear = newnode; }DeletionThe syntax is as follows −Syntaxif ((front= = NULL)) printf("Deletion is not possible, Queue is empty"); else{ temp = front; front ... Read More