- 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)
2K+ Views
The general form of the for statement is as follows −for (initialization; condition; operation) statement;Initialization is an assignment statement which is used to set the loop control variable.Condition is a relational expression that determines when the loop exits.The operation defines that how the loop variable changes each time when the loop is repeated.In for loops, the conditional test is performed at the top of the loop. This means that the code inside the loop may not be executed when the condition is false.To begin with as in the following example −x = 10; for (y=10; y != x; ++y) printf ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
9K+ Views
The exit () function is used to break out of a loop. This function causes an immediate termination of the entire program done by the operation system.The general form of the exit() function is as follows −void exit (int code);The value of the code is returned to the calling process, which is done by an operation system. Generally, zero is used as return code to indicate normal program termination.ExampleFollowing is the C program for use of exit() function −#include void main(){ char ch; printf("B: Breakfast"); printf("L: Lunch"); printf("D: Dinner"); printf("E: Exit"); printf("Enter your choice:"); ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
495 Views
Nested loops consist of one loop placed inside another loop.An example of a nested for loop is as follows −for (initialization; condition; operation){ for (initialization; condition; operation){ statement; } statement; }In this example, the inner loop runs through its full range of iterations for each single iteration of the outer loop.ExampleFollowing is the C program to print the table of first four powers of numbers 1 to 9 by using nested for loop − Live Demo#include void main(){ int i, j, k, temp, I=1; printf("I\tI^2\tI^3\tI^4 "); printf("--------------------------------"); for ( i ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
4K+ Views
In C programming language the reading and writing characters are as follows −The simplest of the console I/O functions are getche (), which reads a character from the keyboard, and putchar(), which prints a character to the screen.The getche () function works on until a key is pressed and then, returns its value. The key pressed is also echoed to the screen automatically.The putchar () function will write its character argument to the screen at the current cursor position.The declarations for getche () and putchar () are −int getche (void); int putchar (int c);The header file for getche () and ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
903 Views
The use of printf is to print out a string with no blank fields to be filled.For example, printf ("An ordinary string.."); printf ("Testing 1, 2, 3...");The next simplest case that has been used before now is to print out a single integer number.int number = 48; printf ("%d", number);The two can be combined as shown below −int number = 48; printf ("Some number = %d", number);The result of this last example is to print out the following on the screen −Some number = 48Here is a list of the different letters for printf −d − signed denary integeru − ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
1K+ Views
Consider the examples given below to understand how to convert a decimal fraction to binary fraction in C programming language.Example 1 − Conversions of 25 to binary.Step 1 − 25 / 2 Rem : 1 , Quo : 12Step 2 − 12 / 2 Rem : 0 , Quo : 6Step 3 − 6 / 2 Rem : 0 , Quo: 3Step 4 − 3 / 2 Rem : 1 , Quo: 1Step 5 − 1 / 2 Rem : 1 , Quo: 0So equivalent binary number is: 11001Example 2 − Conversions of 0.7 to binary.Step 1 − 0.7 * ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
994 Views
ProblemImplement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers and to output the results along with the given integers.SolutionThe solution to implement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers is as follows −The logic used to find GCD and LCM is as follows −if(firstno*secondno!=0){ gcd=gcd_rec(firstno, secondno); printf("The GCD of %d and %d is %d", firstno, secondno, gcd); printf("The LCM of %d and %d is %d", firstno, secondno, (firstno*secondno)/gcd); }The called function is as follows −int gcd_rec(int ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
878 Views
An operator is used to describe an operation applied to one or several objects. It is mainly meaningful in expressions, but also in declarations. It is generally a short sequence using non-alphanumeric characters.A punctuator is used to separate or terminate a list of elements.C operators and punctuators are as follows −... && -= >= ~ + ; ] > % , < ^ >>= *= /= ^= & - = { != ++ | %= +=
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
2K+ Views
Regression is a predictive modelling technique that investigates the relationship between a dependent and non-dependent variable.Polynomial regressionIt is a form of regression analysis that shows the relationship between an independent variable x and the dependent variable y that is modelled a nth degree polynomial in x.ExampleFollowing is the C program to compute the polynomial regression algorithm −#include #include #include main(){ int i,j,k,m,n; float x[20],y[20],u,a[10],c[20][20],power,r; printf("enter m,n:"); scanf("%d%d",&m,&n); for(i=1;i
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
6K+ Views
ProblemWrite a program to implement linear regression algorithm.User has to enter total number of values.SolutionThe solution to compute the linear regression in C programming language is as follows −Linear regression finds the relationship between two variables by connecting a linear equation to the observed data. One variable is to be an explanatory variable, and the other is a dependent variable.The logic with regards to linear regression is explained below −for(i=0;i