ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
what is the output of the following program?
#include<stdio.h>
void main()
{
 float x=1.1;
 while(x==1.1)
  {
   printf("\n%f",x);
   x=x-0.1;
  }
 }
 Question Submitted By :: Vicky
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the output of the following program? #include<stdio.h> void main() { float x=1.1; while(x==1.1) { printf("\n%f",x); x=x-0.1; } }
Answer
# 1
for the first time the loop will be true  and it will print as 1.100000 , after reading the next line x will be 1.0, so again when it comes into while loop 1.000000 not equal to 1.100000 so it will come outside the loop
 
Is This Answer Correct ?    3 Yes 6 No
Vignesh1988i
 
  Re: what is the output of the following program? #include<stdio.h> void main() { float x=1.1; while(x==1.1) { printf("\n%f",x); x=x-0.1; } }
Answer
# 2
first time  loop will satisfy and second time loop will 
not satisfy bcoz x become zero....
 
Is This Answer Correct ?    0 Yes 4 No
Gangadhar
 
 
 
  Re: what is the output of the following program? #include<stdio.h> void main() { float x=1.1; while(x==1.1) { printf("\n%f",x); x=x-0.1; } }
Answer
# 3
No output.Since a float variable is compared with double
constant,condition will not satisfy.
if you don't believe,try your hand on it.
 
Is This Answer Correct ?    5 Yes 0 No
Vikram
 
  Re: what is the output of the following program? #include<stdio.h> void main() { float x=1.1; while(x==1.1) { printf("\n%f",x); x=x-0.1; } }
Answer
# 4
No output.Loop will not execute atleast once. because 
compiler will treat real constant as double. So real 
constants will not store exactly equal to that constant 
value but appproximately equal to that constan in binary 
format. So float value and doule value storing 
approximately equal but not exactly.small difference will 
be there.so condition will fail at first time.So loop will 
not execute atleast once.
 
Is This Answer Correct ?    3 Yes 0 No
Battini.laxman
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is meant by int fun const(int a, int b) { .... ... }  1
what is const volatile?  1
What is the difference between static and global variables?  1
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.  3
#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x=%d",sqr(x+1)); } What is the value of x? Oracle13
How the C program can be compiled? HP7
Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ? Mascot3
how does printf function work  1
1. Write a c pgm to print 1 to 100 without using loops. 2. Write a c pgm for leap year 3. Write a c pgm fibbonacci series,factorial 4. Write a c pgm count no of lines , blanks, tabs in a para(File concept) 5. Write a c pgm to print the letter as per given condition i.e.. if u give 4 out put should b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6.how do get the o/p in number from 1 to 100 in the screen without using control statement? 7. who do u print the word "hello world" without using "printf" statement? 8. write sql program to get the detail of student in a class? Definitions: structure union arrays linkedlist macros directives difference b/w pre processorsDiffrence: 1.Constructors and destructors 2.Structure and Union 3.Array and Lists 4.pre processor... 5. Privillages in C++ 6.structure and union 7.break and continue 8.while and dowhile Pgm..  1
What is the difference between char a[] = "string"; and char *p = "string"; ? Honeywell11
what is object oriental programing?  1
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); } Motorola1
Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….  1
whether itis a structured language? Microsoft1
An interactive c program to read basic salary of 15 persons. each person gets 25% of basic as HRA, 15%of basic as conveyance allowances, 10%of basic as entertainment allowances.The total salary is calculated by adding basic+HRA+CA+EA.Calculate how many out of 15 get salary above 10,000.Rs also print the salary of each employee  2
What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these IBM3
what is the difference between #include<stdio.h> and #include"stdio.h" ? TCS5
do ne body have any idea about the salary for the we r going to have interview. yup .. u got it right ..i m talking abt NIC.  1
How to add two numbers with using function?  3
how to find a 5th bit is set in c program IBM3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com