6. Type arrayname[size];
type int char float
arrayname array
size
int a[12];
array a array
integer a[0] a[1] a[2] a[3] …
a[11]
array
integer array
array
int num1[3]={56,25,89}; num1
array integer
num1[0]=56; num1[1]=25; nu
m1[2]=89;
7. int a[
]={200,230}; a array integer
a[0]
200 a[1] 230
int value[ ]
;
{
} ,
int a[ ]={200,230};
int
money[5];
money[0] = 250; money[4] = 500;
float num[5]; array
float num
num[0] num[1]…
num[4]
array
11. table[0][0] array
type arrayname [r] [c];
type int , float ,char
arrayname array num , word ,x
r,c
r 0,1,2
… , r-1 c 0,1,2 … , c-1 int
num[3][4]; array integer
num[0][0],
num[0][1] ,num[0][2],num[0][3],num[1][0],…,num[2][3]
char word[ ][ ] =
{“Bodin”,”decha”,”Computer”,”Pentium”};
word array x
9
word[0] = “Bodin” word[1] = “dehca” word[2] =
“Computer” word[3] = “Pentium“
int num[2][2];
num[0][1]=3;
array 3
type arrayname[p] [r][c];
type int ,float,char
arrayname
12. r,c,p
array
p 0,1,2 .. , p-1
r 0,1,2, … ,r-1
c 0,1,2 … ,c-1
array
arrays of
arrays
array 3
table
[3][5][4] table[5][4][3]
13. array of arrays
array
table[3][4][5]
table[0][0][0] table[0][0][0] table[0][0]
table[0][0] table[0][4]
table[0] table[0] table[2] tab
le table[3[[5][4] array r *c
*p array
array
array array
array array
14. type arrayname[ ]…[ ]
array
type arrayname
array5_1.c
array
/* array5_1.c */
#include <stdio.h>
#include <conio.h>
main()
{
clrscr();
float num[50];
float sum;
int i,time;
printf(”n Enter the time of input that you want. :”);
scanf(”%d”,&time);
15. sum = 0;
for (i=0;(i+1)<=time;i++)
{
printf(”Please type the floating number for %d round
:”,i+1);
scanf(”%f”,&num[i]);
sum = sum + num[i];
}
printf(”n Input = %d time sum.of them =
%4.2f average of data is%4.2f”, time , sum , sum/time) ;
}
array5_2.c
array
/* array5_2.c */
#include <stdio.h>
#include <conio.h>
main()
{
clrscr();
float num[5][4] ;
17. 1.
for
for (n = ; n <= ; n++)
{
printf ( “ Score = “ ) ;
scanf ( “ %d “ , &score [ n ] ) ;
}
score
scanf
18. n
for (n = ; n < ; n++)
{
}
for (m = ; m <= ; m++)
{
printf ( “ Score = “ ) ;
scanf ( “ %d “ , &score [ n ] [ m] ) ;
}
for
2.
type array_name [ size] = { value list } ;
type array_name [ r ] [ c ] = { value list } ;
19. type array_name [ n ] [ r ] [ c ] = { value list } ;
type int, float, char
array_name
size
value list
,
n]
r]
c]
, , , ,
a[ =
a[ =
a[ =
a[ =
a[ =
int a [ { , , , , };
3.
printf (“ %d” , a[ ;
20. for (n = ; n <= ; n++)
{
printf ( “ Score = %d n” , score [ n ] ) ;
}
score
printf “ Score = %d n” , score [ n
]);
n
for (n = ;n< ; n++)
{
}
for (m = ; m < ; m++)
{
}
for (p = ; p < ; p++)
{
num = score [ n ] [m] [p] ;
22. 2
char arrayname[r][c];
char arrayname[r][c] = {”string
constants0″,”string constants1,…,”string
constants(r-1)};
arrayname
r
c
string constants
r-1
r c-
assignment
(=)
arrayname[2][10] =
{”Bodin”,”12345d,”food};
for , while ,do while
array5_3.c
/* array5_3.c */
#include <stdio.h>
#include <conio.h>
main()
23. {
clrscr();
char name[50][50],changwad[50][30] ; int time,i,j;
printf(”Enter number of Student :”);
scanf(”%d”,&time); i =0;
while (i<=(time-1)) {
printf(”n Enter name of %dth person :”,i+1);
scanf(”%s”,name[i]);
printf(”n Enter changwad of %dth person :”,i+1);
scanf(”%s”,changwad[i]); i++; }
for (j=0;(j+1)<=time;j++)
printf(”n Name of %dth person is %s who live in
%s.”,j+1,name[j],changwad[j]);
}
4 strlen() ,
strcmp(),strcpy(),strcat() string.
h #include <string.h>
strlen()
strlen(”string constant”); strlen(string variables);
24. strlen1.c strlen()
/* strlen1.c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
char word[100]; int length;
void main(void)
{
clrscr();
printf(”Please enter your
strings.”); gets(word); length = strlen(word);
printf(”Your strings is %s.”,word); printf(”nThe
length of strings is %d”,length);
}
strcmp() 2
strcmp(stringvariable1,stringvariable2);
strcmp(stringconstant1,stringconstant2);
ASCII
25. 1 2
1
1 2
0
1 2
1
strlcmp1.c strcmp()
/* strcmp1.c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
char word[100],password[100]={”Bodin”};
int compareresult;
void main(void)
{
clrscr();
printf(”Please enter your strings.”);
gets(word);
compareresult = strcmp(password,word);
if (compareresult > 0)
{printf(”Your strings < Program strings.
compareresult is %d”,compareresult);}
else if (compareresult == 0)
26. {printf(”Your strings = Program strings. compareresult
is %d”,compareresult);}
else
{printf(”Your strings > Program strings. compareresult
is %d”,compareresult);}
}
strcpy()
Strcpy(string2,string1);
string1 string2
strcpy
/* strcpy c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
char word ,word ; clrscr();
printf(”Please enter your st strings :
“); gets(word ;
printf(”Enter your nd strings : “); gets(word ;
printf(”n st strings are :%s nd strings are
:%s”,word ,word ;
27. strcpy(word ,word ;
printf(”n st strings are :%s nd strings are
:%s”,word ,word ;
}
strcat()
strcat(string2 ,string1);
string1 string2
/* strcat c */
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
Char word ,word ; clrscr () ; printf ( “ Please enter
your st strings: ” ) ; gets ( word ;
printf(”Enter your nd strings : “); gets(word ;
printf(”n st strings are :%s nd strings are
:%s”,word ,word ; strcat(word ,word ;
printf(”n st strings are :%s nd strings are
:%s”,word ,word ;
}
29. 3.
long 2
long
int )
4.
float
a.b x 10e 4
3.4E-38 3.4E+38 6
10.625 -6.67
5.
double float
2 8
1.7E-308 1.7E+308
6.
unsigned
unsigned int
Char 8 ASCII character (-128 127)
Unsignedchar 8 0-255
Int 16 -32768 32767
long int 32 -2147483648 2147483649
30. 3.4E-38 3.4E+38
Float 32
6
1.7E-308 1.7E+308
Double 64
12
Unsigned int 16 0 65535
Unsigned long
32 0 4294967296
int
1
1. #include<stdio.h>
2. #define PI 3.14159
3. int area; /* global variable */
4. main( )
5. { float radius; /* local variable */
6. float process() /* function declaration */
7. printf (“Radius = ?”); scanf (“%f”,radius);
8. process( );
9. printf(“Area = %f”,area);
10. printf(“%f”,radius); }
11. float process( )
12. { float radius; /* local variable */
13 printf(“Radius=?”); scanf (“%f”,radius);
14 area=PI*radius*radius;
31. 15 printf(“Area = %f”,area);
16 printf(“%f”,radius); }
2 int a ;
a
-35768 32767
3 int num1=8;
num1
8
4 float money,price ;
money price
6
5 char ch=’A’
ch
1 ‘A’
char a,b,c,d; /* a,b,c,d
character */
unsigned e; /* e unsigned int */
32. char key = ?A?; /* key
character ?A? */
char name = ?SAM? /* name
character ”SAM” */
33.
34. “ ”
“ ”
type array float salary
3.
float
float double char long
8.
float double char long