This document discusses structures in C programming. It explains that structures can contain elements of different data types, accessed by name, unlike arrays where all elements must be of the same type and accessed by index. It provides examples of declaring a structure type with members, defining structure variables, accessing members using the dot operator, passing structures to functions, and initializing an array of structures.
The document discusses call-by-value in function invocation in C. When a function is called, only the values of the arguments are passed to the function, not the variables themselves. So any changes made to the parameters inside the function are not reflected in the calling function. This causes an issue when trying to swap variables by passing them to a Swap function.
2. Use of printf() and scanf()
printf() Print Format 曙企, 覃伎 伎 豢ロ
覈(矧)企.
printf(format string.., argument list);
[Ex]
#include <stdio.h>
int main() {
int n ;
n = 25 * 10;
printf(%d, n);
}
[Ex]
printf(%c%c%c, a, b, c );
printf(%s, def );
/* 250 豢ル. */
/* abc 螳 豢ル. */
/* def 螳 豢ル. */
2
3. Use of printf() and scanf()
Conversion characters (format string)
%c
character (覓語)
printf(%c, a);
%d
decimal integer (10讌襦豢) printf(%d, 100);
%x
Hexadecimal integer
(16讌襦豢)
printf(%x, 100);
%o
Octal integer (8讌襦豢)
printf(%o, 100);
%u
Unsigned decimal (襦豢)
printf(%u, 100);
%e
floating point number in
scientific notation
printf(%e, 1.234);
%f
floating point number
printf(%f, 1.234);
%g
e-format f-format
printf(%g, 1.234);
%s
string (覓語)
printf(%s, C-book);
3
4. Use of printf() and scanf()
The Use of printf() : integer %d
printf( %md, a );
printf( %-md, a);
/*m .るジ讓曙 */
/*m . 殊曙 */
[Ex]
a = 12;
printf(%5d%-5d%dn ,a, a, a+11);
12^^^^^^1223
%5d襦 豢 : 12^^^
( 5襴 殊曙襦 豢, れ 螻糾 朱 螻給葦朱 豈)
%-5d襦 豢 : ^^^12
( 5襴 るジ讓曙襦 豢, 螻糾 朱 螻給葦朱 豈)
%d襦 豢 : 23
(a +11 螳 23 蠏碁襦 豢)
4
5. Use of printf() and scanf()
The Use of printf() : float %f
printf( %m.pf, a );
printf( %-m.pf, a);
/*m, p .るジ讓曙 */
/*m, p . 殊曙 */
[Ex]
83.1260^^83.126083.126000^^^83.13
a = 83.126;
printf(%8.4f%-8.4f%f%-7.2fn, a, a, a, a );
%8.4f : 83.1260^
( 豐 8襴 襯 豢ロ 危 4襴蟾
讌 . )
%-8.4f : ^83.1260
(%8.4f , 蠏碁 襦 誤 るジ讓曙朱 )
%f
: 83.126000
(豺語 危 6襦 豢)
%-7.2f : ^^^83.13
(7襴 覲伎 危 2襴-覦襴, るジ讓 )
5
6. Use of printf() and scanf()
Use of scanf()
scanf() - key board襦覿 data襯 覦蠍 矧
.
scanf(format string.., argument list);
%c
character (覓語)
scanf(%c, &a);
%d
decimal integer (10讌)
scanf(%d, &a);
%f
floating point number (float)
scanf(%f, &a);
%lf
floating point number (double)
scanf(%lf, &a);
%Lf
floating point number (long double)
scanf(%Lf, &a);
%s
string (覓語)
scanf(%s, &a);
6
7. Use of printf() and scanf()
[Ex]
#include <stdio.h>
int main() {
int n ;
printf(Enter number : );
scanf(%d, &n);
printf(You entered : %d, n);
return 0;
}
Enter number : 10
You entered : 10
7