473,892 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mathematic calculation

1 New Member
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 3756
khajeddin
51 New Member
hi:
your program have sevral problems,inclug ing :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 Recognized Expert Top Contributor
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#li mits.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
4017
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 answer. The problem is this: when the user presses the Calculate button, the whole page is reloaded and, on a large page, this is very noticeable. Is there any way that I can get the calculation done and the result displayed without reloading...
0
2489
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 to use a parent window that allows the user to launch the calculation in a seperate window, so that they could still click "stop" to write a value to a database or set a session level variable that the calculation would check to see if it should...
2
3919
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 calculated fields are not being populated. The database is a samll invoicing database on the form and report we have columns call Unit Cost. This is the actual cost of the part and is pulled from our parts master table and is displayed in a sub form...
1
2282
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 between .. I have checked many of the properties to see what got set unintentionally that might make only the first and last record show the values. Has anyone experienced this? I'm baffled.
4
3281
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 program is doing I show a window which contains a progress bar and a label. At some point during the execution the state of the calculation is changed, so I want to let the user know this. I have placed the creation of the form in a seperate thread...
4
3766
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 calculation is very simple. The calculation is done in an underling query if I can call it a query or I should call it a SQL statement. It looks like a query but it is not saved as the query. The calculation in that query is very simple - ExtendedPrice:*....
5
6267
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 user modifies any of the x, y and z values.
3
3559
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 know nothing about advanced math, so I wrote a C program to help me: (BTW, I guess the result would be ln2.) #include <stdio.h>
7
9226
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 perform the required operation like add, subtract, %calculation.
0
9830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11241
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10836
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10926
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10468
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5857
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4683
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4279
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.