Saturday, November 14, 2015

Aptitude Q's in C

Q :
1.main()
{
int i=10;
i=!i>14;
printf(“i=%d”,i);
}
try it   results zero
Explanation :
i>14 is 0
!i>14 is 0
reason
!i means !10 is 0
then 0>14 is zero

interpret the stmt like this
i=(!i)>14;   results 0

try it for i=!(i>14); results 1


Wednesday, October 28, 2015

Excel element no to sheet address program in c

#include<stdio.h>
main()
{
 int n,a[20],r,i=0,j;
 clrscr();
 printf("enter element:\n");
 scanf("%d",&n);
 while(n>0)
 {
  r=n%26;
  if(r==0)
  {
   r=26;
   n=n-1;
  }
  a[i]=r;
  i++;
  n=n/26;
 }
 for(j=i-1;j>=0;j--)
  printf("%c",a[j]+64);
 getch();
} 

Arrange Array Elements Using Array Index

# include <stdio.h>
 # include <conio.h>

 /* arrange array */
 main()
 {
  int i[5]={4,3,1,0,2};
  int val[5]={7,9,10,1,8};
  int j,pos,tmp,tmp_pos;
  int x,y;

  for(x=0;x<=3;x++)
  {
  for(y=x+1;y<=4;y++)
  {
   if(i[x]>i[y])
   {
    tmp=val[x];
    val[x]=val[y];
    val[y]=tmp;
    tmp=i[x];
    i[x]=i[y];
    i[y]=tmp;
   }
  }
  }

  clrscr();


  for(j=0;j<=4;j++)
  printf("%3d,",val[j]);


}

Saturday, May 2, 2015

TT TEST-II Java Programming For #rd Yr

Technical Test - 2


1.What modifiers are allowed for methods in an Interface?
a)abstract, public    b)abstract,private    c)none  
2 .Can there be an abstract class with no abstract methods in it? 
   a)yes    b)no
3. Can we instantiate an abstract class?
     a)yes    b)no
4. Is it possible to override the main method?
a)yes    b)no
       5. Can we create an object for an interface?
a)yes    b)no
       6. Is null a keyword?
a)yes    b)no
       7. out object is member of which class ?
            a)PrintStream    b)System   c)OutStream     d)InStream
       8.next() is a member of which class?
            a)BufferReader    b)DataInputStream   c)Scanner    4)none
       9. How we can access library classes members ________________
     10. class x
             {          public dis() { System.out.println(“RISE@GSK”); }
                         Public static void main(String[]args){
                        new  x().dis();}
             }
            Guess the output
            a)compile time error   b)run time error    c)RISE@GSK    d)none

     11. class MyClass
             {         
                         public  void  main(String[]args){
System.out.println(“RISE@GSK”);
                        }
             }

            a)compile time error   b)run time error    c)RISE@GSK    d)none

     12.      
What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
                 a)2      b)3     c)4     d)2.5
13.What is the prototype of the default constructor?
Test( )
Test(void)
public Test( )
public Test(void)
14. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
public
private
protected
transient

15.Which will legally declare, construct, and initialize an array?
A.int [] myList = {"1", "2", "3"}; B. int [] myList = (5, 8, 2); C. int myList [] [] = {4,9,7,0};
D. int myList[] = {4, 3, 7};


Tuesday, April 28, 2015

TECHNICAL TEST2

TECHNICAL TEST2     by RVS
-----------------------------------------------------------------------------------------------------
1.#include<stdio.h>
int main(){
    int i,j;
    i=j=(2,3),0;
    while(--i&&j++)
         printf(" %d %d",i,j);
    return 0;
}
a)1 3     b)none  c)13  02  d)24 25

2. int main()
{
            int i=1,n;
            clrscr();
            for(i=0,n=0;i<=5;n+=i++);
            printf("%d",n,n=9);
}

a)25      b)21      c)9        d)15

3.int main()
{
char c=’a’;
do
printf("%d ",c);
while(c--);
return 0;
}
a) finate loop prints 65,64,63….0  
b)infinite loop c)compilation error d) finite loop prints 65,66,67……

4. #include<stdio.h>
int main()
{
                int i=10;
                int no[2][4]={1,0,2};
                printf("%d",sizeof(no));

}
a)6          b)8         c)2          d)16

6. main(){
 char*str=”I love java”;
str=str+3;
printf(“%s”,str);
}
a.i love java        b)error   c)ove java    d)ve java
 7.
void main()
{
char *s="\123\n";
printf("%d",sizeof(s));
}
a)4   b)2    c)6     d)error
8. main()
{
  char *str="ECETT";
clrscr();

printf("%s   %s   %c  ",str+1,str,*str++);
}
a)ETT CETT E   b)ECE TT T  c)error    d)CET CETT C

9. main()
{
  char a[]="%d\n";
  clrscr();
a[1]='c';
printf(a,68);
getch();
}
a)error    b)D     c)c      d)D with new line
10.
main()
{
            printf(“%d”,10?0?5:1:12)
}
a) 1      b)12      c)12      d)0

11. void main()
{
int a=3;
clrscr();
if(a==1);
a=2<<1;
printf("%d",a,a=~a);
}

     a.   4
     b.     nothing
     c.     -5
     d.     1

12. main(){
 char*s={”I love java”};
printf(“%c”,s[0]);
}
a)error   b)i love java   c)I     d)null

13. #include<stdio.h>
main()
{
  char not=!EOF;
  clrscr();
  printf("\n%d %d",EOF,not);
}
a. 0 0    b.error  c.-1 0   d.-1 1

14.
 # include <stdio.h>
main()
{
 char not='\0';
int i;
i=not==NULL;
clrscr();
printf("%d",i);
}
a.48                  b.compile time error
c.0                    d.1


15.What will be output of following c code?
        
#include<stdio.h>
int main(){
    int i=3,j=2;
    clrscr();
    while(i--?--j:j++)
             printf("%d",j);
    return 0;
}

a.-1      b)0 1     c)0        d)1


16 (5 marks)

Print the following using loops

54321012345









Monday, April 27, 2015

TEST - 3: C-PROGRAMMING:



GRAND  TEST : C-PROGRAMMING:
1#include<stdio.h>
void main()
{
            clrscr();
            if(printf("0"))
            printf("true");
            else
            printf("false");
}
a)true  b)0true            c)false d)0
----------------------------------------------------------
2.#include<stdio.h>
void main()
{
            char ch='A0';
            clrscr();
            
            printf("%d",ch);

}
a)0    b)a          c)65     d)error
----------------------------------------------------------
3.#include<stdio.h>
void main()
{
            int ch=NULL || EOF+1 && EOF ;
            clrscr();
            printf("%d",ch);
}
a)0       b)1       c)-1      d)48
----------------------------------------------------------
4.#include<stdio.h>
void main()
{                       printf("a\/b=c");
}
a)a=c   b)a\/b=c          c)a/b=c                        d)error
----------------------------------------------------------
5.#include<stdio.h>
void main()
{           clrscr();
printf("%d",1||printf("ok"));
}
a)1       b)1ok   c)error d)ok1
6.#include<stdio.h>
void main()
{
            float x=10.2345F;
            int a;
            clrscr();
            a=x-(int)x;
            printf("\n%f",(float)a);
}
a)10.234500                b)0.000000                  c)error                         d)10.2345
7.#include<stdio.h>
void main()
{
            clrscr();
            printf("a%cb",'\\b');
}
a)a\b               b)a\\b              c)b       d)error
8.#include<stdio.h>
void main()
{
            float f=2.0;
            clrscr();
            printf("%d",sizeof(f));

}
a)4       b)8       c)6       d)error

----------------------------------------------------------
9. #include<stdio.h>
void main()
{
            char ch='ab';
clrscr();
            do
            {
                        printf("%c",ch++);
            }while(ch!='c'+1);}
a)abc   b)ab     b)abcd             d)error
10. #include<stdio.h>
void main()
{
            enum color{red,green=3,blue};
clrscr();
            printf(“\n %d”,red+green);
}
a)5       b)3       c)0       d)none
11. #include<stdio.h>
void main()
{char ch='0a';
                switch(ch)
                {
                case '0a':
                                puts("\nfirst");  break;
                                case 48:
                                puts("\nsecond");break;
                                default:                printf("wrong");
                }
}
a)first  b)wrong     c)error      d)second
12. #include<stdio.h>
void main()
{
            int a=5^8;
            printf("%d",a*a);
}
a)13     b)169   c)-169  d)-13
13.        #include <stdio.h>
        int main()
        {            int i = 0, j = 0;
            while (i < 5, j < 10)
            {
                i++;        j++;
            }
            printf("%d, %d\n", i, j);
        }
a)0,0    b)5,5    c)10,10    d)error
14. #include <stdio.h>
        int main()
            {           int a=7,b=2;
printf("\n%d",(int)((float)a/b-(int)a/b));
        }
a)0.5    b)0       c)0.500000      d)error
15. #include <stdio.h>
        int main()
            {
            int i=10,j=9;
            clrscr();
                        while(--i && j++);
                        printf("\n%d %d",i,j);
        }
a)1   19            b)0   18           c)1  10 d)1  19

16.write a program to print .  print   (6  marks )
            0
            1 0
            0 1 0
            1 0 1 0
            0 1 0 1 0