11CS ProgramBasedTest1 Answers
11CS ProgramBasedTest1 Answers
LESSONS – 9 & 10
Name: ________________________
WRITE THE OUTPUT OF THE FOLLOWING SNIPPETS. / பின்வரும் குறிமுறைகளின் வெளியீட்டை எழுதுக.
1) cout<<(10/3)<<endl;
cout<<(10%3);
3
1
2) cout<<(8.5 % 2);
Error!
3) cout<<((int)8.5 % 3);
2
4) int i = 8, j = 10, k = 8;
cout<<(i <k )<<endl;
cout<<(i == j)<<endl;
cout<<(i != k )<<endl;
cout<<(I >= k);
0
0
0
1
5) int a = 5, b = 6, c = 7;
cout<<((a>b) && (b>c))<<endl;
cout<<((a<b) || (b>c));
0
1
6) #include <iostream.h>
using namespace std;
int main ()
{
..1.. A. PRABHAKAR - 9442979144
int n=100;
char ch;
ch = n;
cout << "\n Equivalent Character: " << ch;
}
Equivalent Character: d
7) #include <iostream.h>
using namespace std;
int main()
{
const int num=100;
cout << "\n Value of num is = " << num;
num = num + 1;
cout << "\n Value of num after increment " << num;
}
Error!
8) #include <iostream>
using namespace std;
int main()
{
int m3;
int practical = 30;
int &physics = m3;
m3 = 51;
physics = physics + practical;
cout << "\n The physics mark = " << physics;
}
The physics mark = 81
9) #include <iostream.h>
using namespace std;
int main( )
{
float a = 78.685;
cout<<"a = "<<(int)a;
}
a = 78
Wednesday
Thursday
15) #include <iostream>
using namespace std;
int main ()
{
int i;
..4.. A. PRABHAKAR - 9442979144
for(i = 0; i<= 10; i+=2)
cout<< "value of i : " <<i<<endl;
return 0;
}
value of i : 0
value of i : 2
value of i : 4
value of i : 6
value of i : 8
value of i : 10
16) #include <iostream>
using namespace std;
int main ()
{
int i, sum=0;
for(i=1; i<=10;i++);
{
sum=sum+i;
}
cout<<"The sum of 1 to 10 is "<<sum;
}
The sum of 1 to 10 is 11
17) #include <iostream>
using namespace std;
int main ()
{
int i, sum=0;
while(i<=10)
{
sum=sum+i;
i=i+1;
}
cout<<"The sum of 1 to 10 is "<<sum;
}
The sum of 1 to 10 is 55