TCS NQT Input/Output Quiz 1

Question 1

Time: 00:00:00
What will be the final value of the res when INPUT N1=100?

Function F(INPUT N1)
Static int res=0;
IF(N1>0)
    res=res+1
    F(N1/20)
END IF
return res
END Function

3

3

2

2

1

1

Error

Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will be the output of the following pseudo code

Integer x,y,z
x=2
y=1
z=5
Do
Print z--
while((x & y)|| (z+1))
End loop

5 4 3 2 1 0

5 4 3 2 1 0

5 4 3 2 1 1

5 4 3 2 1 1

4 3 2 1 0 0

4 3 2 1 0 0

4 3 2 1 1 1

4 3 2 1 1 1

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the output of the following code?

Set integer _no1=0, _no2=1, _no3=1, _lower=6, _inc=1
while _inc is less than equals to _lower:
_inc is increment by 1
Print _no3
_no3=_no1+_no2
_no1 equals to _no2
_no2 equals to _no3
End While

1 2 3 5 8

1 2 3 5 8

3 5 8

3 5 8

1 1 2 3 5 8

1 1 2 3 5 8

2 3 5 8

2 3 5 8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Find the output of the following code

#include<stdio.h>
int main ()
{
   int num;
   printf ("enter number" );
   scanf ("%d", &num);
   no = (num * 2) + 3 ;
   (no & 1 && printf ("odd"))printf ("even") 
   return 0;
}

Enter a number: Odd

Enter a number: Odd

Odd

Odd

Error : ‘no’ undeclared

Error : ‘no’ undeclared

Even

Even

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What will be the output of the following code?

#include<stdio.h>
int main()
{
  while(){
   printf(“hello world”);
  }
return 0;
}

 

Compile error

Compile error

No output will be printed

No output will be printed

hello world

hello world

Infinite loop

Infinite loop

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What is the output of the following code

class A{
public int i;
public int j;
A(){
    i=1;
    j=2;
  }
}
class B extends A{
    int a;
    B(){
       super();
    }
}
class transform {
    public static void main(String,args[]){
        B obj = new B();
        System.out.println(obj.i+""+obj.j);
    } 
}

1 2

1 2

Compile-time error

Compile-time error

Run-time error

Run-time error

No output

No output

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What will be the output of the following code

#include <stdio.h>
#define LowerLimit 10
int main(){
    auto int x=10;
    switch(x,x*2){
        case LowerLimit:
        printf("ABC");
        break;
        case LowerLimit*2:
        printf("XYZ");
        break;
        case LowerLimit*3:
        printf("PQR");
        break;
        default:
        printf("MNO");
        case LowerLimit*4:
        printf("www");
        break;
    }
}

ABC

ABC

XYZ

XYZ

Compile time Error

Compile time Error

No output

No output

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What will be the output of the following code ?

#include <stdio.h>
int main()
{
    int a=64;
    double b=256;
    int *x=&a;
    double *y=&b;
    printf("x and y are %d and %d",sizeof(x),sizeof(y));
    return 0;
}

Compilation error

Compilation error

x and y are 8 and 8

x and y are 8 and 8

x and y are 1 and 2

x and y are 1 and 2

Run-time error

Run-time error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What would be the output of the below code?

#include <stdio.h>
int main ()
{
  int n, num = 8421;
  n = num;
  while (num >= 10)
  {
    num /= 10;
  }
  printf ("%d", num);
  return 0;
}

16

16

4

4

8

8

2

2

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What is the output of the following code  when inputChar = ‘y’

#include <stdio.h>
int main()
{
   char inputChar;
   printf("%d",scanf("%c",&inputChar));
   return 0;
}

1

1

Garbage value

Garbage value

Compile-time error

Compile-time error

Run time error

Run time error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects