What is the outcome of the line of code "cout<<abs(-
16.5);"?




1) 16


2) 17


3) 16.5

Answers were Sorted based on User's Feedback



What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / shailaja

the outcome of this code is 16.5
bcz it will return the absolute value of parameter.

Is This Answer Correct ?    18 Yes 6 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / prabakaran

1)16
because abs() is used to calculate the absalute value of
integer only,so it convert the floating point value -16.5
into -16,and
calculate tha abs() value

Is This Answer Correct ?    8 Yes 2 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / rajavel

16.5
this is abs value

Is This Answer Correct ?    7 Yes 2 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / d n gavade

abs() function returns absolute value of given arguments in
integer form because its return type is integer.
so answer will be 16.

if it is fabs() then only we get answer in float,double.

Is This Answer Correct ?    5 Yes 1 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / neeraj

16

Is This Answer Correct ?    5 Yes 2 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / pds

16

Is This Answer Correct ?    3 Yes 1 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / ankit

I ran it on my PC and got the result as 16

Is This Answer Correct ?    3 Yes 1 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / arash s

16
just read what is "absolute" and u will know why.

Is This Answer Correct ?    1 Yes 0 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / nathusingh rathod

Right answer for this question is 16. Had there been fabs
then result would have been 16.5 but as there is only abs()
so it will return integer value i.e 16.

Is This Answer Correct ?    1 Yes 0 No

What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 ..

Answer / deep

16.5

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

What polymorphism means?

0 Answers  


#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

0 Answers  


Which type does string inherit from?

0 Answers  


What is difference between abstraction and encapsulation?

0 Answers  


What are the components of marker interface?

0 Answers  






What is a class oop?

0 Answers  


wht is major diff b/w c and c++?

10 Answers  


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

0 Answers   TCS,


what is the difference between ERROR and EXCEPTION?

14 Answers   NIIT, nvidia,


What is encapsulation example?

0 Answers  


How to overload postfix operator in c++

1 Answers   Mphasis,


write a c++ code of diagonal matrix.

2 Answers  


Categories