Write a programm such that
if user enter 11.25 it roundup to 11
but if user enter 11.51 upto 11.99 it will round up to 12
i.e.;convert the floting point value into integer format as
explain above..

Answers were Sorted based on User's Feedback



Write a programm such that if user enter 11.25 it roundup to 11 but if user enter 11.51 upto 11.9..

Answer / vadivel t

#include<stdio.h>
#include<math.h>
void main()
{
double no = 12.34, no1, intpart;
no1 = modf(no, &intpart);
if(no1 >= 0.5)
{
printf("ROUNDED VALUE: %f",++intpart);
}
else
{
printf("ROUNDED VALUE: %f",intpart);
}
_getch();
}

Is This Answer Correct ?    2 Yes 0 No

Write a programm such that if user enter 11.25 it roundup to 11 but if user enter 11.51 upto 11.9..

Answer / gsrinivas

#include<sdtio.h>
#include<math.h>
void main()
{
float x;
int y;
printf("\n entere the no");
scanf("%f",&x);
y=ceil(x);
y=floor(x);
printf("\n %d",y);
}

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

Explain how can I open a file so that other programs can update it at the same time?

0 Answers  


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

0 Answers  


can u suggest me am in a confusion to choose whether to go to c programming or a software testing . am a graduate in B.sc(electronics).

1 Answers  


What oops means?

0 Answers  


Why doesn't the code "a[i] = i++;" work?

4 Answers  






how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0

4 Answers   Wipro,


Explain what is the difference between #include and #include 'file' ?

0 Answers  


I need previous papers of CSC.......plz help out by posting them.......

0 Answers  


What is calloc in c?

0 Answers  


write a recursive program in'c'to find whether a given five digit number is a palindrome or not

2 Answers  


When should we use pointers in a c program?

0 Answers  


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

0 Answers  


Categories