Professional Documents
Culture Documents
:
.
.
.
) (Arrays .
:
.1
.2
.3
.4
.5
.
.
.
.
.
: :
" :
".
) (char ) (int ) (float
) (float, int, char
.
.
) (
.c++
.c++
:
:
One Dimensional Arrays
. .
.
Multidimensional Arrays
.
.
.
5 6.
: :
.
.
20
30
25
1
1
1
1
a
b
mem
1
1
;]int a[20
;]char b[30
;]float mem[25
20
30
2
10
200
10 3
10
10
2
10
20
;]int d[20][30
stack
char
;]stack[10][200
char
;]x[10][10][10
double
;]y[10][20
:
;}int a[]={1,2,3,4,5,6
a
12345. 6
;}}float b[][]={{1,2,3},{4,5,6},{7,8,9
B 3 .
1 :2 .3 45. 6
78.9
;}char c[]={a,n,o
: :
.
for
while do while for
.
) (
.
:
.
.
.
.
:
.
: 1
.
:
#include<iostream.h>
void main(void)
{
int degrees[25],i,n;
float sum,average;
cout<<Enter number of students n please /n;
cin>>n;
sum=0;
for(i=0;i<n;i++)
{
cout<<Enter the degree of student no. <<i<<please \n;
cin<<degrees[i];
sum=sum+degrees[i];
}
average=sum/n;
cout << The average of degrees is <<average<<\n;
}
. %20 :2
:
#include<iostream.h>
void main(void)
{
int salary[100],i,n;
float average;
cout<<Enter number of employees n please /n;
cin>>n;
for(i=0;i<n;i++)
{
cout<<Enter the salary of employee no. <<i<<please \n;
cin<<salary[i];
salary[i]= salary[i]*(1.2);
cout<<Salary after increasing= <<salary[i]<<\n;
}
}
:3
:
:
include<iostream.h>
void main(void)
{
int a[10][10],b[10][10],c[10][10],i,j,m,n;
cout<<Enter number of rows and columns please m and nplease /n;
cin>>m>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<Enter the the elements of matrices a and b for row #<<i<<and col. #<<j<<
please\n;
cin>>a[i][j]<<b[i][j];
cout<<The sum of the matrix is given by= <<c[i][j]<<\n;
}
}
:3
welcome name name
:
# include<iostream.h>
#include<string.h>
void main(void)
{
char namr[80]
)(
:
.
.
dbase MS-Access FoxPro
records
fields . C
struct
.Record
.
) (structures .
:
.1
.2
.3
.4
.
.
.
.
: :
) (
.
:
:
-1
.
-2
.
-3 typedef
.
struct
.
struct
.
.
:
struct structure_name
{
;type1 field1
;type2 field2
.
.
.
;typen fieldn
;}
structure_name .
var1,var2,,varn structure_name :
;struct structure_name var1,var2,,varn
:
struct S
{
;int a
;float b
;char c
float d
;]char name[20
;}
S 5 :
a b c d name string 20. )( S :
;struct S x,y,z
x,y,z .
.S
struct
.
.
. :
struct structure_name
{
;type1 field1
;type2 field2
.
.
.
;typen fieldn
;} var1,var2,,varn
structure_name .
var1,var2,,varn .
:
struct S
{
;int a
;float b
;char c
float d
;]char name[20
;} x,y,z
S 5 :
a b c d name string 20. x,y,z .S
typedef
struct
.
. .
:
typedef struct
{
;type1 field1
;type2 field2
.
.
.
;typen fieldn
;} structure_name
structure_name .
var1,var2,,varn .
;structure_name var1,var2,,varn
:
typedef struct
{
;int a
;float b
;char c
float d
;]char name[20
;} S
S 5 :
a b c d name string 20. x,y,z S
;S x,y,z
:
.
". :
;cin>>x.b
b x .S
;cout <<y.d
d y S .
;z.d=x.b+y.d
d z b S
d y . S
.
)( -
.
. employee
.
- employee
struct employee
{
char name[40];
char address[40];
int age;
float salary;
}
struct dept
{
int deno;
int product;
sturct employee emp;
}
:- -
:
#include <stdio.h>
#include <conio.h>
#include<iostream.h>
void main ()
{
struct data
{
int num;
char stat;
};
struct data stud;
stud.num = 5;
stud. stat='t';
cout<<"\n stud.num =<< stud.num<< stud.stat="<< stud. stat;
getch();
}
:-
employee department employee gets name emp :
;)gets(dept.emp.name
printf .
:
:
>#include<iostream.h
>#include <stdio.h
>#include <conio.h
)( void main
{
struct data
{
;int no
;]char name[10
;}
stud1.name= tamer
stud2.name= tamer
: Structures Nested
.
#include <stdio.h>
#include <conio.h>
#include<iostream.h>
void main()
{
struct person{
int no;
char name[10];
};
struct group{
struct person P1;
};
struct group G1;
cout<<"\n\n G1.P1.no= ";
cin>>G1.P1.no;
cout<<\n G1.P1.name= ";
cin>>G1.P1.name;
cout"\n G1.code = ";
cin>>G1.code;
G1.P2=G1.P1;
cout<<"\n\n The data of Groups :\n\t";
cout<<\n\t G1.P1.no=<<G1.P1.no;
cout<<"\n\t G1.P1.name="<<G1.P1.name;
cout<<"\n\t G1.code="<<G1.code;
cout<<"\n\t G1.P2.no "<<G1.P2.no;
cout<<"\n\t G1.P2.name=<<G1.P2.name;
G1.P1.no= 10
G1.P1.name= Samer
G1.code =199
The data of Groups :
G1.P1.no=10
G1.P1.name= Samer
G1.code=199
G1.P2.no=10
G1.P2.name= Samer