File tree 5 files changed +141
-18
lines changed
5 files changed +141
-18
lines changed Original file line number Diff line number Diff line change
1
+ // code by vishwa
2
+ #include < iostream>
3
+ using namespace std ;
4
+ int main ()
5
+ {
6
+ float num1,num2,sum,avg;
7
+
8
+ cout<<" Enter two numbers :" ;
9
+ cin>>num1>>num2;
10
+
11
+ sum=num1+num2;
12
+ avg = sum/2 ;
13
+
14
+ cout<<" the sum of two numbers are :" <<sum<<endl;
15
+
16
+ cout<<" the average of two numbers are :" <<avg<<endl;
17
+
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ // code by vishwa
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ class integer {
6
+ int m,n;
7
+
8
+ public:
9
+ integer (int ,int );
10
+
11
+ void display (void )
12
+ {
13
+ cout<<" m = " <<m <<" \n " ;
14
+ cout<<" n = " <<n <<" \n " ;
15
+ }
16
+ };
17
+
18
+ integer ::integer (int x,int y)
19
+ {
20
+ m=x ;
21
+ n=y ;
22
+ }
23
+ int main ()
24
+ {
25
+ integer int1 (0 ,100 );
26
+ integer int2 =integer (25 ,75 );
27
+
28
+ cout<<" OBJECT 1 :" ;
29
+ int1.display ();
30
+
31
+ cout<<" OBJECT 2 :" ;
32
+ int2.display ();
33
+
34
+ return 0 ;
35
+ }
Original file line number Diff line number Diff line change
1
+ // code by vishwa
1
2
#include < iostream>
2
3
using namespace std ;
3
-
4
- class A
4
+ class sample
5
5
{
6
- int a,b;
7
- public:
8
- void input ()
9
- {
10
- cout<<" enter the two numbers :" ;
11
- cin>>a>>b;
12
- }
13
- friend void add (A obj);
6
+ int a;
7
+ int b;
8
+ public:
9
+ void setvalue ()
10
+ {
11
+ a=25 ;
12
+ b=40 ;
13
+ }
14
+ friend float mean (sample m);
14
15
};
15
- void add (A obj )
16
+ float mean ( sample m )
16
17
{
17
- int c;
18
-
19
- c=obj.a +obj.b ;
20
- cout<<" addtion of two number is :" <<c;
18
+ return float ( m.a + m.b )/2.0 ;
21
19
}
22
20
int main ()
23
21
{
24
- A object;
25
- object.input ();
26
- add (object);
22
+ sample a;
23
+ a.setvalue ();
24
+ cout<<" mean value :" <<mean (a)<<" \n " ;
25
+
26
+ return 0 ;
27
27
}
Original file line number Diff line number Diff line change
1
+ // code by vishwa
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ class set
6
+ {
7
+ int n,m;
8
+
9
+ public :
10
+ void input (void );
11
+ void display (void );
12
+ int largest (void );
13
+ };
14
+
15
+ int set ::largest (void )
16
+ {
17
+ if (m>=n)
18
+
19
+ return (m);
20
+ else
21
+ return (n);
22
+ }
23
+
24
+ void set :: input(void )
25
+ {
26
+ cout<<" Enter input value for m and n : \n " ;
27
+ cin>>m>>n;
28
+
29
+ }
30
+ void set :: display(void )
31
+ {
32
+ cout<<" largest value : \n " <<largest ()<<" \n " ;
33
+
34
+ }
35
+ int main ()
36
+ {
37
+ set A;
38
+ A.input ();
39
+ A.display ();
40
+
41
+ return 0 ;
42
+ }
Original file line number Diff line number Diff line change
1
+ // code by vishwa
2
+ #include < iostream>
3
+ using namespace std ;
4
+ int m=10 ; // global data m
5
+ int main ()
6
+ {
7
+ int m=20 ; // local data m
8
+ {
9
+ int k=m;
10
+ int m=30 ;
11
+
12
+ cout<<" we are in inner block :\n " ;
13
+ cout<<" k= " <<k <<" \n " ;
14
+ cout<<" m = " <<m <<" \n " ;
15
+ cout<<" :: m = " <<::m <<" \n " ;
16
+ }
17
+
18
+ cout<<" \n we are in outer block :\n " ;
19
+ cout<<" m = " <<m <<" \n " ;
20
+ cout<<" :: m = " <<::m <<" \n " ;
21
+ return 0 ;
22
+ }
23
+
24
+
25
+
26
+
27
+
You can’t perform that action at this time.
0 commit comments