This is code which I wrote for learning of new function "round".
#include <stdio.h>
#include <cs50.h>
int main(void);
float a = 0;
float b = 0;
{
do
{
// Here we will ask fo the change.
printf("How much change do I owe?\n");
float a = GetFloat();
}
while (a <= 0);
{
// Use of new function round which will round off the float and conver it to int or any specified number format.
float b = (int)round( a * 100);
printf("%f\n", b);
}
return 0;
}
But it gives the following error
greedy.c:6:1: error: expected identifier or '(' { ^ 1 error generated. make: *** [greedy] Error 1
look you have some syntax and logical problems :
#include <stdio.h>
int main()
{
float a = 0;
do
{
// Here we will ask fo the change.
printf("How much change do I owe?\n");
scanf("%f",&a);
// Use of new function round which will round off the float and conver it to int or any specified number format.
a = (int)(a * 100);
printf("%f", a);
}
while (a <= 0);
return 0;
}