Professional Documents
Culture Documents
1973.
APPLICATION OF C PROGRAMMING
ARE LISTED BELOW
DATA TYPES
char
int
float
double
FORMAT SPECIFIERS
%c
char single character
%d (%i) int signed integer
%e (%E) float or double exponential format
%f
float or double signed decimal
%o
int unsigned octal value
%p
pointer address stored in pointer
%s
array of char sequence of characters
%u
int unsigned decimal
%x (%X) int unsigned hex value
#include <stdio.h>
int main()
{
int val;
printf(hello %n hello\n", &val);
printf("val = %d\n", val);
return 0;
}
Output:
hello hello
val = 6
#include<stdio.h>
void main()
{
char a= 6;
printf(%d, a);
}
Output:
54
printf("%d",A');
65
#include<stdio.h>
int main()
{
int _=5;
int __=10;
int ___;
___=_+__;
printf("%i",___);
return 0;
}
Ans: 15
#include<stdio.h>
int main()
{
int class=150;
int public=25;
int private=30;
class = class >> private - public;
printf("%d",class);
return 0;
}
Ans: 4
#include<stdio.h>
int main()
{
register x_a=5;
auto b_1=10;
const _1a1_=b_1+~x_a;
printf("%d",_1a1_);
return 0;
}
Ans: 4
in t m ain ()
{
reg ister in t i = 10;
in t *a = & i;
p rin tf("% d ", *a);
g etch ar();
retu rn 0;
}
If you use & operator with a register variable then
compiler may give an error or warning (depending upon the
compiler you are using), because when we say a variable
is a register, it may be stored in a register instead of
memory and accessing address of a register is invalid.
in t m ain ()
{
in t i = 10;
reg ister in t *a = & i;
p rin tf("% d ", *a);
g etch ar();
retu rn 0;
}
in t m ain ()
{
in t i = 10;
reg ister static in t *a = & i;
p rin tf("% d ", *a);
g etch ar();
retu rn 0;
}
Register is a storage class, and C doesnt allow multiple
storage class specifiers for a variable. So,registercan not
be used withstatic.
C TOKENS CHART
In C Programmingpunctuation, individual
words, charactersetc are calledtokens.
Tokens arebasic building blocksof C
Programming.
MACROS
#include <stdio.h>
#define foo(x, y) x / y + x
int main()
{
int i = -6, j = 3;
printf("%d\n",foo(i + j, 3));
return 0;
}
Ans: -8
#include <stdio.h>
#define foo(x, y) #x #y
int main()
{
printf("%s\n", foo(a, b));
return 0;
}
Ans: ab
WHAT IS LVALUE ?
Example of LValue :
#include<stdio.h>
int main()
{
int num;
num = 5;
return(0);
}
In the above expression, Constant value 5 is being
assigned to a variable num. Variable num is called as
storage regions , num can considered as LValue of an
expression.
int main()
{
int num;
5 = num; //Error
return(0);
}
WHAT IS R-VALUE ?
Example of RValue :
#include<stdio.h>
int main()
{
int num;
num = 5;
return(0);
}
In the above example, Constant Value 5 is assigned to the
variable will be considered as right Value of the variable.