Sunday, December 28, 2014

Datatype(4)

1:
 #include <stdio.h>  
 int main()  
 {  
     int a, b, sum;  
     a = 10;  
     b = 2;  
     sum = a / b;  
     printf("%d\n", sum);  
     return 0;  
 }

output:  5

2:
 #include <stdio.h>  
 int main()  
 {  
     int a, b, sum;  
     a = 10;  
     b = 2;  
     sum = a - b;  
     printf("%d\n", sum);  
     return 0;  
 }

output: 8

3:
#include <stdio.h>  
 int main()  
 {  
     double a, b, sum;  
     a = 5;  
     b = 2;  
     sum = a / b;  
     printf("%.2lf\n", sum);  
     return 0;  
 }

output:  2.50

/***here %lf is double idientifier***/

4:
#include <stdio.h>  
 int main()  
 {  
     double a, b, sum;  
     a = 2.5;  
     b = 2;  
     sum = a * b;  
     printf("%.2lf\n", sum);  
     return 0;  
 }

output:  5.00

No comments:

Post a Comment