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

What is const keyword in c?

0 Answers  


Mention four important string handling functions in c languages .

0 Answers  


what is c++ programming?

3 Answers   TCS,


Why doesnt long int work?

0 Answers  


what is the function of pragma directive in c?

0 Answers  






Give differences between - new and malloc() , delete and free() ?

0 Answers   Genpact,


#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?

4 Answers   Ramco,


Who had beaten up hooligan "CHAKULI" in his early college days?

1 Answers  


Write a C program that reads a series of strings and prints only those ending in "ed"

2 Answers   Accenture,


Explain function pointer with exapmles.

2 Answers  


1,1,5,17,61,217,?,?.

3 Answers   Apple,


What are the types of unary operators?

0 Answers  


Categories