Академический Документы
Профессиональный Документы
Культура Документы
a. 687.0312510 hexadecimal
b. 24.68 decimal
c. 101101012 decimal
d. 10110111 . 11112octal
e. FACE . ACE binary
III. Identify the syntax errors in the following programs. Rewrite the corrected programs and
underline the corrections.
a.
main( )
{int n1=5 , n2=0;
n1/=n2;
n+3 = n1 != n2 ? n1;
}
b.
void main( )
{ long float f(4.5); int i=1.25;
if(f)
cout<<"True"<<endl;
f = i + 10.5;
else if
cout<<"False";
f = 20.5 - i; }
c.
void main( )
{ char chr = 'B' , ch = 'W';
switch(chr);
{case 'B' : case 66: cout<<"Black"<<endl; break;
case ch : cout<<"White"<<Endl; break;
default case : cout<<"Invalid"<<endl;} }
IV. Find the output of the following codes. Assume that all header files are included.
a.
void main ( )
{float a = 0.5, b = 0.9 ;
if(a&&b>0.9)
cout<<”IF PART”;
cout<<”ELSE PART”; }
b.
void main( )
{int a=29,b=2,c;
c = (float) (a/b);
cout<<c; }
c.
void main( )
{ int x=1;
cout<<(x=x+2)<<endl;
cout<<!x<<endl;
}
d.
void main()
{ int a=1,b=2,c=3,d=4.75,x;
for(; ;)
{ if(i>3) break;
else j+=i;
cout<<j<<endl;
i+=j;
}
}
f.
void main ( )
{ int x = 10,y,z;
z = y = x;
y - = x- -;
x - = - -x - x;
cout<<y<<' '<<x; }
c. What do you mean by an entry controlled and an exit controlled loop. Give 1 difference.
e. Explain implicit and explicit type conversions with an example for each.
Note : A pair of numbers are automorphic if the sum of factors of one number equals to
the other numbers and vice versa.
Example 220 and 284 . Sum of all the factors of 220 equals to 284 and vice versa.
e. WAP to accept numbers into an integer array of size 6 and call a function ALTSWAP( ) .
The function swaps the alternate locations only if the number is a factor of 10.
Example : if the original array is
90 1 5 20 7 3
Then the swapped array is
1 90 5 7 20 3
f. Write a function FINDMAX( ) that would accept a 2D integer array and its row and
column size as arguments. The function displays the biggest number of each row.
Incorporate a main( ) function to accept the array and pass it to the function.
g. WAP to accept a string and count the number of words which are palindromes in it.
Incorporate a function PALIN( ) that would accept one word at a time and checks if it is
a palindrome or not. The function returns 1 if true else it returns 0.Counting is done in
main( ).