simple explanation for float and int

Greetings blogger friends healthy this time I wrote an article titled explanation float and int.

Of the headache thinking about the task better sit stacked in depen laptop to a friend for sharing semua.Yang first to know that int is short for integer that is to receive the data in the form of numbers like 1,2,3,4,5. While float receive data 1.5,3.4,5.6 be essentially used to execute more details float and int numbers desiimal numbers for sure.

See an example of a simple program that I created using int as below:

#include<stdio.h>
main() {

int c,d ;

printf("masukkan bilangan 1 = ");
scanf("%d",&c);

printf("masukkan bilangan 2 = ");
scanf("%d",&d);

printf("\nhasil = %d\n",c + d);

return 0 ;

}


will produce output like this:

whereas example a simple program to use float:
#include<stdio.h>
main() {

float c,d ;

printf("masukkan bilangan 1 = ");
scanf("%f",&c);

printf("masukkan bilangan 2 = ");
scanf("%f",&d);

printf("\nhasil = %f\n",c + d);

return 0 ;

}

and will generate output like this:

Good luck

No comments:

Post a Comment