Sample papers >>  
                                                                
   PCS- Question paper - 05   Conducted On -- -2003   

    

  1. #include 
      /* This problem is given in PCS BOMBAY walk-in-interview.
      * What is the final value of i and how many times loop is
      * Executed ?
      */
     
      main()
     
      {
      int i,j,k,l,lc=0;
      /* the input is given as 1234 567 */
      printf("Enter the number string:<1234 567 >\n");                                            Freshersworld.com
     scanf("%2d%d%1d",&i,&j,&k);
     for(;k;k--,i++)
     for(l=0;l> printf("%d %d\n",i,l);}
     printf("LOOPS= %d\n", lc-1);
      }
      /* Ans: i = 17, and loop is executed for 169 times */

  2. #include 
    main()
      {
      func(1);
      }
      func(int i){
      static char *str[] ={ "One","Two","Three","Four"};
     printf("%s\n",str[i++]);
      return;
      }
      /* Ans:- it will give warning because str is pointer to the char but                           Freshersworld.com
      it is initialized with more values
      if it is not considered then the answer is Two */

  3. #include 
      main()
      {
      int i;
      for (i=1;i<100; i++)
      printf("%d %0x\n",i,i);
      }
      /* Ans:- i is from 1 to 99 for the first format,
      for the second format 1to9, ato f, 10 to 19,1ato1f, 20 to 29, etc */ 

  4. #include 
    /* This problem was asked in PCS Bombay in a walk-in-interview
      * Write a recursive function that calculates
      * n * (n-1) * (n-2) * ....... 2 * 1
      */
     
      main() {
      int factorial(int n);
      int i,ans;
     printf("\n Enter a Number:");
     scanf("%d",&i);
      ans = factorial(i);
     printf("\nFactorial by recursion = %d\n", ans);
      }
      int factorial(int n)
      {
      if (n <= 1) return (1);
      else
      return ( n * factorial(n-1));
      }

  5. #include 
      /* This problem is asked in PCS Bombay walk-in-interview                        Freshersworld.com
      * What is the output of the following problem
      */
      main(){
      int j,ans;
      j = 4;
      ans = count(4);
     printf("%d\n",ans);
      }
      int count(int i)
      {
      if ( i < 0) return(i);
      else
      return( count(i-2) + count(i-1));
      }
     
      /* It is showing -18 as an answer */ 

  6. #include 
      /* This problem is given in PCS BOMBAY walk-in-interview.
      * What is the final value of i and how many times loop is
      * Executed ?
      */
     
      main()
     
      {
      int i,j,k,l,lc=0;
      /* the input is given as 1234 567 */
      printf("Enter the number string:<1234 567 >\n");                                        Freshersworld.com
     scanf("%2d%d%1d",&i,&j,&k);
     for(;k;k--,i++)
     for(l=0;l> printf("%d %d\n",i,l);}
     printf("LOOPS= %d\n", lc-1);
      }
      /* Ans: i = 16, and loop is executed for 169 times */

Google
 
Web freshersworld.com

 Copyright © 2004 Freshersworld.com, All rights reserved.