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
2 3756
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. -
#include<stdio.h>
-
#include<conio.h>
-
void main()
-
{
-
long no,x;
-
-
clrscr();
-
printf("Enter numbor : ");
-
scanf("%ld",&no);
-
x=no*3000;
-
printf("%ld",x);
-
getch();
-
}
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> -
/* Program 9_2, display integral sizes and ranges */
-
-
#include <stdio.h>
-
#include <limits.h>
-
-
int main(void)
-
{
-
printf("\nchar size %2d bytes, range %11d to %11d ",
-
(int) sizeof(char), CHAR_MIN, CHAR_MAX);
-
printf("\nsigned char size %2d bytes, range %11d to %11d ",
-
(int) sizeof(signed char), SCHAR_MIN, SCHAR_MAX);
-
printf("\nunsigned char size %2d bytes, range %11d to %11d ",
-
(int) sizeof(unsigned char), 0, UCHAR_MAX);
-
printf("\nshort int size %2d bytes, range %11d to %11d ",
-
(int) sizeof(short int), SHRT_MIN, SHRT_MAX);
-
printf("\nunsigned short int size %2d bytes, range %11u to %11u ",
-
(int) sizeof(unsigned short int), 0, USHRT_MAX);
-
printf("\nint size %2d bytes, range %11d to %11d ",
-
(int) sizeof(int), INT_MIN, INT_MAX);
-
printf("\nunsigned int size %2d bytes, range %11u to %11u ",
-
(int) sizeof(unsigned int), 0, UINT_MAX);
-
printf("\nlong int size %2d bytes, range %11ld to %11ld ",
-
(int) sizeof(long int), LONG_MIN, LONG_MAX);
-
printf("\nunsigned long int size %2d bytes, range %11lu to %11lu ",
-
(int) sizeof(unsigned long int), 0L, ULONG_MAX);
-
return 0;
-
}
-
for example Turbo C V3.01 uses 16-bit to store an int -
char size 1 bytes, range -128 to 127
-
signed char size 1 bytes, range -128 to 127
-
unsigned char size 1 bytes, range 0 to 255
-
short int size 2 bytes, range -32768 to 32767
-
unsigned short int size 2 bytes, range 0 to 65535
-
int size 2 bytes, range -32768 to 32767
-
unsigned int size 2 bytes, range 0 to 65535
-
long int size 4 bytes, range -2147483648 to 2147483647
-
unsigned long int size 4 bytes, range 0 to 4294967295
-
The GNU gcc compiler on the same machine uses 32-bits -
char size 1 bytes, range -128 to 127
-
signed char size 1 bytes, range -128 to 127
-
unsigned char size 1 bytes, range 0 to 255
-
short int size 2 bytes, range -32768 to 32767
-
unsigned short int size 2 bytes, range 0 to 65535
-
int size 4 bytes, range -2147483648 to 2147483647
-
unsigned int size 4 bytes, range 0 to 4294967295
-
long int size 4 bytes, range -2147483648 to 2147483647
-
unsigned long int size 4 bytes, range 0 to 4294967295
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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.
|
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...
| |
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:*....
|
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.
|
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>
|
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.
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |