473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mathematic calculation

1
Hi friends,,

I'm new in c programming
need your help,,
I just do a simple mathematics calculation

#include<stdio.h>
void main()
{
int no,x;
clrscr();

printf("Enter numbor : ");
scanf("%d", &no);

x=no*3000;
printf("%d", x);
getch();
}

if I put 30, the output that I will get is 44464.. should be 90000,
can someone help me..

thanks
Nov 10 '06 #1
2 3731
hi:
your program have sevral problems,incluging :speling and errors.
well, you have to pay attention to the capacity of "int".as you have to know that you're allowed to put numbers from " -32768 to 32767 "in the" int variables" ,even you use the "unsinged int variables" you're allowed to put numbers less than 65536 in it.
so what u have to do is to chang the type of variables to "long int" or "long"that have capacity about " 0 to 4294967296 ",and please correct your speling too.and olso we don't have getch() and clrscr() in<stdio.h> you should add <conio.h> too the libraries.

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. long no,x;
  6.  
  7. clrscr();
  8. printf("Enter numbor : ");
  9. scanf("%ld",&no);
  10. x=no*3000;
  11. printf("%ld",x);
  12. getch();
  13. }
Nov 10 '06 #2
horace1
1,510 Expert 1GB
the maximum numeric range an int can hold is compiler and system dependent and you can determine these from the header file <limits.h>, see
http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html#limits.h

the following program will print out useful information from <limits.h>
Expand|Select|Wrap|Line Numbers
  1.  /* Program 9_2, display integral sizes and ranges */
  2.  
  3. #include <stdio.h>
  4. #include <limits.h>
  5.  
  6. int main(void)
  7. {
  8.     printf("\nchar               size %2d bytes, range %11d to %11d ",
  9.                  (int) sizeof(char), CHAR_MIN, CHAR_MAX);
  10.     printf("\nsigned char        size %2d bytes, range %11d to %11d ",
  11.                  (int) sizeof(signed char), SCHAR_MIN, SCHAR_MAX);
  12.     printf("\nunsigned char      size %2d bytes, range %11d to %11d ",
  13.                  (int) sizeof(unsigned char), 0, UCHAR_MAX);
  14.     printf("\nshort int          size %2d bytes, range %11d to %11d ",
  15.                  (int) sizeof(short int), SHRT_MIN, SHRT_MAX);
  16.     printf("\nunsigned short int size %2d bytes, range %11u to %11u ",
  17.                  (int) sizeof(unsigned short int), 0, USHRT_MAX);
  18.     printf("\nint                size %2d bytes, range %11d to %11d ",
  19.                  (int) sizeof(int), INT_MIN, INT_MAX);
  20.     printf("\nunsigned int       size %2d bytes, range %11u to %11u ",
  21.                  (int) sizeof(unsigned int), 0, UINT_MAX);
  22.     printf("\nlong int           size %2d bytes, range %11ld to %11ld ",
  23.                  (int) sizeof(long int), LONG_MIN, LONG_MAX);
  24.     printf("\nunsigned long int  size %2d bytes, range %11lu to %11lu ",
  25.                  (int) sizeof(unsigned long int), 0L, ULONG_MAX);
  26.     return 0;             
  27. }
  28.  
for example Turbo C V3.01 uses 16-bit to store an int
Expand|Select|Wrap|Line Numbers
  1. char               size  1 bytes, range        -128 to         127 
  2. signed char        size  1 bytes, range        -128 to         127 
  3. unsigned char      size  1 bytes, range           0 to         255 
  4. short int          size  2 bytes, range      -32768 to       32767 
  5. unsigned short int size  2 bytes, range           0 to       65535 
  6. int                size  2 bytes, range      -32768 to       32767 
  7. unsigned int       size  2 bytes, range           0 to       65535 
  8. long int           size  4 bytes, range -2147483648 to  2147483647 
  9. unsigned long int  size  4 bytes, range           0 to  4294967295 
  10.  
The GNU gcc compiler on the same machine uses 32-bits
Expand|Select|Wrap|Line Numbers
  1. char               size  1 bytes, range        -128 to         127 
  2. signed char        size  1 bytes, range        -128 to         127 
  3. unsigned char      size  1 bytes, range           0 to         255 
  4. short int          size  2 bytes, range      -32768 to       32767 
  5. unsigned short int size  2 bytes, range           0 to       65535 
  6. int                size  4 bytes, range -2147483648 to  2147483647 
  7. unsigned int       size  4 bytes, range           0 to  4294967295 
  8. long int           size  4 bytes, range -2147483648 to  2147483647 
  9. unsigned long int  size  4 bytes, range           0 to  4294967295
  10.  
Nov 10 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
7
by: vinay2110 | last post by:
i m new to .net programing and dont know how to apply mathematic calculation on the text box. i has the idea to do this thing using auto post back but i dont know what is the exact syntax which will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.