Now that we know quite a bit about programming lets try to mend some problems into our programs.

You all know that how using integer values to store (result of) a float neglects the decimal part. We can make use of this logic to separate the decimal part from the whole number.

What i mean to say is

I know you might be wondering y only one program. the thing is i got this idea for a simple program and wanted to share it. Without the knowledge of comparisons and loops there not a lot different that can be done, hence i have reserved a lot of fun practice programs after we learn a little more on programming.

You all know that how using integer values to store (result of) a float neglects the decimal part. We can make use of this logic to separate the decimal part from the whole number.

What i mean to say is

**if you are given a number like 3.4563**write a program to separate the decimal part. So**the program should only print 0.4563****For those who cant figure out the solution can use the code below.**

/* Author : Ryan Sequeira Date : 12th September 2012 Title : implementing a complex equation with short hand */ #include<conio.h> #include<stdio.h> void main() { float num=34.3345,result; int temp; clrscr(); //our logic temp = num; // this will store the number without the decimal part result = num - temp; // this will subtract non decimal part printf("The decimal part is : %f",result); getch(); }

I know you might be wondering y only one program. the thing is i got this idea for a simple program and wanted to share it. Without the knowledge of comparisons and loops there not a lot different that can be done, hence i have reserved a lot of fun practice programs after we learn a little more on programming.

## No comments:

## Post a Comment