C program

Loser

New Member
I have to write one that reads a number and increases it by 25%. So far, I have written this...

main ()
{
inta
intb
b=1.25
a=a*b
printfa
}

Any help?
 
Last edited:

strollin

Well-Known Member
Your title says Assembly program but what you have written is certainly not Assembler language, looks like C.

You have both a and b declared as integers but the result of (a * 1.25) will not be an integer so you need to declare b as a different type.

You need to initialize a to the number you want to increase by 25%. I see that your statement says the program is supposed to read a number. Should it read the number from a file or read it from the console? You need to add code to read that number from wherever and assign it to the variable a.

Your printf line is incomplete, google printf to find out what is missing.
 

Loser

New Member
This is my next effort.

include <stdio.h>
main ()
{
inta
floatb
b=1.25
printf('enter a number:')
scanf('%d', a)
a=a*b
printf('%d\a', a)
}
return 0
}
 

strollin

Well-Known Member
That looks much better. Does it compile and run? Is your goal to compile and run this program?

I think you would be better off declaring BOTH a and b as float, not int. You also need to fix your printf and scanf statements to allow for decimal numbers.

There are some syntax errors as well, you need semi-colons at the ends of your lines of code. The first line should be #include<stdio.h>. The last right brace isn't needed.
 
Last edited:
Top