-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3.cpp
116 lines (93 loc) · 3.2 KB
/
day3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include<iostream>
using namespace std;
int main()
{
//variabes
int a=10;
int b=20; //integer take 4 byte
cout<<"The value against A and B is:"<<a<<" "<<b<<endl;
cout<<"Size of variable A is:"<<sizeof(a)<<endl;
cout<<"Size of variable B is:"<<sizeof(b)<<endl;
char name='a';
cout<<"The value of the name is: "<<name<<" and Size of char "<<sizeof(name)<<endl;
bool value=true;
cout<<"The value of the bolean is: "<<value<<" size of "<<sizeof(value)<<endl;
double val=134465758; //precedence upto 15 value
cout<<"The value of doube val is: "<<val<<" size of val is:"<<sizeof(val)<<endl;
float num=32.1;
cout<<"The value of float value is:"<<num<<" size of num is:"<<sizeof(num)<<endl;
int apple; //take input from the user
cout<<"Enter the number for the apple:"<<endl;
cin>>apple;
cout<<"The total number for the apple is: "<<apple<<endl;
//take two number from the user nad print their sum:
int num_1=20;
int num_2=30;
cout<<"Enter the Number1 and Number2: "<<endl;
cout<<"The sum of two number is : "<< num_1+num_2 <<endl;
//increment decrement pre increment and vice versa
int value1=30;
cout<<"post increment:"<<value1++<<endl; //it will print 30 then increase value
cout<<"The value after inrement is:"<<value1<<endl;
//now the pre increment same like pre decrement
int value2=23;
cout<<"The orignal value is:"<<value2<<endl;
cout<<"The value after pre increment is:"<<++value2<<endl;
//swap two number y using third variable
int number1=12;
int number2=13;
cout<<"The orignal value of number1 is:"<<number1<<endl;
cout<<"The orignal value of number2 is:"<<number2<<endl;
int temp=number1;
number1=number2;
number2=temp;
cout<<"The value after swapping"<<endl;
cout<<"Now the value of the Number1 is: "<<number1<<endl;
cout<<"Now the value of the Number2 is: "<<number2<<endl;
//now the relational operator
int number_1=12;
int number_2=15;
cout<<"The Comparison opr is:"<<(number_1==number_2)<<endl; //it will give the zero becuase num1 and num2 not same
cout<<"The not equal opr is:"<<(number_1 != number_2)<<endl; //it will true
cout<<"The number_1 > number_2 is:"<<(number_1 > number_2)<<endl; //it will return 0
cout<<"The number_1 < number_2 is:"<<(number_1 < number_2)<<endl;
//logical operator
// && || ~ //1 for false and 0 for true
int exp1=5;
int exp2=6;
cout<<"The && operator is: "<<(exp1 && exp2)<<endl; //it will gave falase
cout<<"The || operator is: "<<(exp1 || exp2)<<endl;
//bitwise operator
int expersiion=11;
cout<<"The left shift operator is: "<<(expersiion<<2)<<endl; //(left-shift) it will gave us 44 answer
cout<<"The Right shift operator is: "<<(expersiion>>2)<<endl; //right shift operator gave 2 result
//switch case
int expression_number;
cout<<"Enter the number of the week 1 to 7"<<endl;
cin>>expression_number;
switch (expression_number){
case 1:
cout<<"its Monday..";
break;
case 2:
cout<<"its Tuesday..";
break;
case 3:
cout<<"its wednensday..";
break;
case 4:
cout<<"its Thursday..";
break;
case 5:
cout<<"its friday..";
break;
case 6:
cout<<"its Saturday..";
break;
case 7:
cout<<"its Sunday..";
break;
default:
cout<<"Number is invalid"<<endl;
}
}