Data Types in C++
Data Types in C++
Muhammad Bilal
[email protected] 3
Prepared By:
Muhammad Bilal
[email protected] 3
Prepared By:
Muhammad Bilal
[email protected] 3
Prepared By:
Muhammad Bilal
Struct test{
Int data1;
Float data2;
Char data3;
}
[email protected] 3
Prepared By:
Muhammad Bilal
Class test{
Int data1;
Float data2;
Char data3;
//class body
}
[email protected] 3
Prepared By:
Muhammad Bilal
Usually one dimensional array is also called a vector. Whereas, the matrix have rows or
coloumns. So, two dimensional array can perform a complete functionality. For example, we can add two
matrices, similarly we can do this with two dimensional array.
1 2 3 11 12 13 12 14 16
4 5 6 + 14 15 16 = 18 20 22
7 8 9 17 18 19 24 26
28
void main()
clrscr();
arr1[3][3]={1,2,3,
4,5,6,
7,8,9};
*/it may be as
arr1[3][3]={1,2,3,4,5,6,7,8,9};
*/
[email protected] 3
Prepared By:
Muhammad Bilal
arr2[3][3]={11,12,13,
14,15,16,
17,18,19};
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
arr1[i][j] = arr2[i][j];
getch();
#include<conio.h>
[email protected] 3
Prepared By:
Muhammad Bilal
#include<dos.h>
class Time
private :
int hh,min,sec;
public :
Time()
hh=0;
min=0;
sec=0;
void tim()
for(int i=0;sec<65;i++)
clrscr();
if(sec>59)
sec=0;
min++;
[email protected] 3
Prepared By:
Muhammad Bilal
min=0;
hh++;
delay(1000);
sec++;
};
void main()
clrscr();
Time TimeObj;
TimeObj.tim();
getch();
[email protected] 3
Prepared By:
Muhammad Bilal
#include<iostream.h>
struct date
int dd;
int month;
int year;
};
void main()
clrscr();
date d1;
d1.dd=15;
d1.month=9;
d1.year=1430;
if(d1.month>29)
d1.month++;
else if(d1.year>12)
d1.year++;
getch();
[email protected] 3
Prepared By:
Muhammad Bilal