- 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)
356 Views
First, let us learn about the logical operator.Logical operatorThese are used to combine 2 (or) more expressions logically.They are logical AND (&&) logical OR ( || ) and logical NOT (!)Logical AND (&&)exp1exp2exp1&&exp2TTTTFFFTFFFFLogical OR(||)exp1exp2exp1||exp2TTTTFTFTTFFFLogical NOT(!)exp!expTTFTOperatorDescriptionExamplea=10, b=20, c=30Output&&logical AND(a>b)&&(a20)&&(10b)||(a20)||(10b)!(10>20)1ExampleFollowing is the C program to compute logical operators − Live Demo#include main (){ float a=0.5, b=0.3, c=0.7; printf("%d", (ac));//0// printf("%d", (a>=b)&&(b=a)||(a==c));//0// printf("%d", (b=a));//0// printf("%d", !(b=a));//1// }OutputYou will see the following output −0 1 0 0 0 1Assignment OperatorIt is used to assign a value to a variable.TypesThe types of assignment operators are −Simple assignmentCompound assignmentOperatorDescriptionExample=simple assignmenta=10+=, -=, *=, ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
770 Views
These are used for comparing the two expressions.OperatorDescriptionExamplea=10, b=20Output=200==equal toa==b10==200!=not equal toa!=b10!=201Relational expression output is either true (1) (or) false (0).AlgorithmFollow the algorithm given below −START Step 1: Declare integer variables. Step 2: Read all variables at runtime. Step 3: Perform relational operations. i. a=b v. a==b vi. a!=b Step 4: Print all computed values.ExampleFollowing is the C program to compute relational operators − Live Demo#include main (){ int a, b; printf("enter a, b values:"); scanf("%d%d", &a, &b); printf("%d", a=a); printf("%d", a==b); printf("%d", a!=b); }OutputYou will see the following output −enter a, ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
3K+ Views
An expression is a combination of operators and operands which reduces to a single value. An operation is performed on a data item which is called an operand. An operator indicates an operation to be performed on data.For example, z = 3+2*1z = 5Primary expressions − It is an operand which can be a name, a constant or any parenthesized expression. Example − c = a+ (5*b);Postfix expressions − In a postfix expression, the operator will be after the operand. Example − ab+Prefix expressions − n a prefix expression, the operator is before the operand. Example − +abUnary expression − ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
2K+ Views
A ‘C’ program contains executable statements. A compiler helps to translate the executable statements into machine language.When a user runs the program, he/she machines the language statements which are executed by the compiler.Types of executable statementsThe types of executable statements in C language are as follows −Input – output statementsAssignment statementsInput-output statementsStoring a value into memory is called ‘input operation’.After executing the computations, the results are stored in memory and the results can be displayed to the user by ‘output operation’.All i/o operations are performed using input / output functions.The most common I/O functions are supplied through the preprocessor directive ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
10K+ Views
Let us first understand, what is a variable.VariableIt is the name for memory location that may be used to store a data value.A variable may take different values at different times during execution.A variable name may be chosen by the programmer in a meaningful way, so as to reflect its function (or) nature in the program.For example, sum, avg, total etc.Rules for naming variableThe rules for naming a variable are explained below −They must begin with a letter.Maximum length of variable is 31 characters in ANSI standard. But, first eight characters are significant by many compilers.Upper and lowercase characters are ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
3K+ Views
The link and definition sections are called as preprocessor directives. It gives instructions to the compiler to link function from the system library.For example, the definition section defines all the symbolic constants.#includeFor example, #define PI 3.1415The preprocessor directives must start with # symbol.Without link definition the program will not execute for some compilers. It helps the compiler to link the predefined functions from system library.Predefined FunctionsThe predefined functions present in stdio.h are as follows −FunctionDescriptionprintf()Print the character, string, float, integer, octal onto the screen.scanf()Read a character, string, numeric data from keyboard.getc()Reads character from file.gets()Reads line from keyboard.getchar()Reads character from keyboard.puts()Writes ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
1K+ Views
In this program, we are trying to sort out the odd numbers and even numbers that are present in one file. Then, we try to write all odd numbers in ODD file and even numbers into EVEN file.Open a file DATA in write mode and write some numbers into the file and later on close it.Again, Open DATA file in read mode.Open ODD file in write mode.Open EVEN file in write mode.Then, perform the operations to check odd and even numbers by using while loop.After that close all files.ExampleFollowing is the C program to handle integer data files using file ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
5K+ Views
The pre-processor is a program which process the source code before it passes through compiler. It operates under the control of different command lines or directives.Pre-processor are placed in source program before the main line, it begins with symbol# in column one and do not require a semicolon at the end.The commonly used pre-processor directives are −#define, #undef, #include, #ifdef, #endif, #if, #else….The pre-processor directives are divided into three categories −Macro substitution directive.File inclusion directive.Compiler control directive.Macro Substitution directiveThe syntax and an example is as follows −SyntaxGiven below is the syntax for macro substitution directive −#define identifier stringExample − simple ... Read More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
8K+ Views
Enter two numbers at console during runtime. Then, declare the flag variable which is used to check whether the number is prime or not with the help of for loop condition.Whenever, the flag is zero, it prints the prime number and if flag is one, it exists from the loop.ProgramFollowing is the C program to display the prime numbers in between two intervals − Live Demo#include int main(){ int number1, number2, i, j, flag; printf("enter the two intervals:"); scanf("%d %d", &number1, &number2); printf("prime no’s present in between %d and %d:", number1, number2); for(i=number1+1;iRead More
![Bhanu Priya](https://www.tutorialspoint.com/assets/profiles/314653/profile/60_78287-1615027882.jpg)
3K+ Views
The sum of first and last digit for a number can be calculated if we use the below mentioned algorithm in C programming language.AlgorithmRefer an algorithm given herewith −START Step 1: Declare no, sum variables of type int Step 2: Read a number at runtime Step 3: Compute sum=no%10 Step 4: While loop no>9 No=no/10 Step 5: Compute sum=sum+no; Step 6: Print sum STOPExampleFollowing is the C program to find the sum of first and last digit for a number − Live Demo#include int main(){ unsigned int no, sum; printf("enter any number:"); scanf("%u", &no); sum=no%10; ... Read More