instead « integer « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » integer » instead 

1. C - Rounding integer division up (instead of truncating)    stackoverflow.com

I was curious to know how I can round a number to the nearest tenth whole number. For instance, if I had:

int a = 59 / 4;
which would be 14.75 calculated ...

2. Should int *p be long int *p instead?    stackoverflow.com

I'm learning c by reading K&R and doing the exercises. I'm now in chapter 5 which deals with pointers. I don't understand why the statement:

int *p;
is not:
long int *p;
since ...

3. Having scanf in C return void instead of int    stackoverflow.com

If I have a program that is using scanf to get user inputted data:

    scanf("%d",&val);
When I run it through lint I get warnings saying that scanf returns a ...

4. why static flag instead of static int flag doesnot give any error?    stackoverflow.com

see once in hurry i have written

#include <stdio.h>

static flag;            
int main()
{
printf("flag is %d",flag);
return 0;
} 
it does not not give ...

5. Print a short instead of an int... ? What's up with "%hd"?    bytes.com

Martin Wells wrote: When passing arguments to a VAL function, all integer types are promoted, and floats become doubles. Therefore, signed short will be promoted to signed int. Therefore I can't see any reason why you'd have: > printf( "%hd", my_short); > instead of: > printf( "%d", my_short); I believe that the purpose is to allow the use of the same ...

6. Using integer variables instead of double to calculate compound interest    cboard.cprogramming.com

/* Fig. 4.6: fig04_06.c Calculating compound interest */ #include #include int main() { int year; double amount, principal = 1000.0, rate = .05; printf( "%4s%21s\n", "Year", "Amount on deposit" ); for ( year = 1; year <= 10; year++ ) { amount = principal * pow( 1.0 + rate, year ); printf( "%4d%21.2f\n", year, amount ); } return 0; ...

7. why int main instead of void main?    cboard.cprogramming.com

Well, actually you have to think about this from the perspective of the operating system, not the perspective of you writing code. Regardless of how you prototype main(), the Operating System, arbitrarily expects the application to push an integer onto the stack at time of exit. You get away with 'void' here, because a) it doesn't matter, the whole application heap ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.