C Assignment - Assignment Operator in C
Learn C - C tutorial - assignments in c - C examples - C programs
C Assignment - Assignment Operator in C
- Once you've declared a variable you can use it - attempts to use a variable that has not been defined will cause a compiler error.
- You can store a value in a variable using name = value;
- For example:
- k=100;
Sample Code
#include <stdio.h>
int main()
{
float x, p ;
double y, q ;
unsigned k ;
int m = 54321 ;
long int n = 1234567890 ;
x = 1.234567890000 ;
y = 9.87654321 ;
k = 54321 ;
p = q = 1.0 ;
printf("m = %d\n", m) ;
printf("n = %d\n", n) ;
printf("x = %.12lf\n", x) ;
printf("x = %f\n", x) ;
printf("y = %.12lf\n",y) ;
printf("y = %lf\n", y) ;
printf("k = %u \np = %f\nq = %.12lf\n", k, p, q) ;
}
Output
m = 54321
n = 1234567890
x = 1.234567880630
x = 1.234568
y = 9.876543210000
y = 9.876543
k = 54321
p = 1.000000
q = 1.000000000000