Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views7 pages

11CS ProgramBasedTest1

mol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

11CS ProgramBasedTest1

mol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

11 – COMPUTER SCIENCE

LESSONS – 9 & 10
Name: ________________________

என்றும் மாணவர்கள் நலனில்

WRITE THE OUTPUT OF THE FOLLOWING SNIPPETS. / பின்வரும் குறிமுறைகளின் வெளியீட்டை எழுதுக.

1) cout<<(10/3)<<endl;
cout<<(10%3);

2) cout<<(8.5 % 2);

3) cout<<((int)8.5 % 3);

4) int i = 8, j = 10, k = 8;
cout<<(i <k )<<endl;
cout<<(i == j)<<endl;
cout<<(i != k )<<endl;
cout<<(I >= k);

5) int a = 5, b = 6, c = 7;
cout<<((a>b) && (b>c))<<endl;
cout<<((a<b) || (b>c));

6) #include <iostream.h>
using namespace std;
int main ()
{
int n=100;
char ch;
ch = n;
cout << "\n Equivalent Character: " << ch;
}

..1.. A. PRABHAKAR - 9442979144


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;
}

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;
}

9) #include <iostream.h>
using namespace std;
int main( )
{
float a = 78.685;
cout<<"a = "<<(int)a;
}

10) #include <iostream>


using namespace std;
int main( )
{
char ch = 'A';
ch = ch + 5;
cout<<ch;
}
..2.. A. PRABHAKAR - 9442979144
11) #include <iostream>
using namespace std;
int main( )
{
int num = 6;
cout<<num<<endl;
cout<<(num==5);
}

12) Fill the right word in the blanks of the following C++ program:
#include <iostream.h>
using namespace std;
int main()
{
int num;
cout<< "\n Enter a number: ";
cin>>num;
if (num % 2 != 0)
cout<< "\n The given number" <<num<< " is _______ ";
else
cout<< "\n The given number "<<num<< " is ________ ";
return 0;
}

13) #include <iostream>


using namespace std;
int main()
{
int num = -16;
int res = (num%2==0)?1:0;
if (res)
cout<<"Even";
else
cout<<"Odd";
return 0;
}

..3.. A. PRABHAKAR - 9442979144


14) #include <iostream>
using namespace std;
int main()
{
int num = 4;
switch (num)
{
case 1 : cout << "\n Sunday";
case 2 : cout << "\n Monday"; break;
case 3 : cout << "\n Tuesday"; break;
case 4 : cout << "\n Wednesday";
case 5 : cout << "\n Thursday"; break;
case 6 : cout << "\n Friday";
case 7 : cout << "\n Saturday"; break;
default: cout << "\n Wrong input....";
} }

15) #include <iostream>


using namespace std;
int main ()
{
int i;
for(i = 0; i<= 10; i+=2)
cout<< "value of i : " <<i<<endl;
return 0;
}

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;
}
..4.. A. PRABHAKAR - 9442979144
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;
}

18) #include <iostream>


using namespace std;
int main ()
{
int n = 10;
do
{
cout<<n<<", ";
n--;
}while (n>0) ;
}

19) for (int i=1; i<10; i++)


cout<<i;

20) for (int i=0; i<=10; i++)


cout<<i;

21) int i;
for (i=0; i<=10; i++);
cout<<i;

22) for (int i=0; ; i++)


cout<<i;
..5.. A. PRABHAKAR - 9442979144
23) for (int i=1; ; i++)
{
cout<<i;
if (i==5)
break;
}

24) for (int i=2; i<=10 ; i+=2)


cout << i;

25) #include<iostream>
using namespace std;
int main()
{
int i, sum = 5;
for( i = 1 ; i <= 5 i++)
{
sum = sum + i;
}
cout<<sum;
return 0;
}

26) #include<iostream>
using namespace std;
int main(){
int i = 1, sum = 0;
while (i <= 10)
{
sum=sum+i;
i++;
}
cout<<sum;
return 0;
}

..6.. A. PRABHAKAR - 9442979144


27) #include<iostream>
using namespace std;
int main()
{
int i;
for( i = 0; i < 8; i++)
cout<< i <<endl;
return 0;
}

28) Correct the following code segment:


int x=5, p;
if (x=1)
p= 100;
else
p = 10;

29) Rewrite the following code so that it is functional:


v = 5;
do;
{
total += v;
cout << total;
while v <= 10

30) Correct the following code segment:


int a, x=25, m = 10;
if x >= 10
a = m + 5;
else
a = m - 5;

..7.. A. PRABHAKAR - 9442979144

You might also like