Friday, April 22, 2016

Floating point error in c - struct

 //Link float error solution  
 #include<stdio.h>  
 #include<conio.h>  
 struct Employee{  
      int empno;  
      char name[50];  
      float salary;  
 };  
 void floatError(float *a){  
      float b=*a;  
      floatError(&b);  
 }  
 void showDetails(struct Employee *emp){  
      printf("\n %d  %s %f",emp->empno,emp->name,emp->salary);  
 }  
 void main(){  
      struct Employee e1;  
      struct Employee e2;  
      clrscr();  
      e1.empno=1001;  
      strcpy(e1.name,"Krishna G");  
      e1.salary=29999.879;  
      e2.empno=1002;  
      strcpy(e2.name,"Nanda Gopal Krishna");  
      e2.salary=59999.987;  
      showDetails(&e1);  
      showDetails(&e2);  
      getch();  
 }  

No comments:

Post a Comment

Spring Boot 3 : JWT with SecurityFilterChain, AuthorizeHttpRequests, RequestMatchers

pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"...