# different things to do, where to start?

This is a discussion on different things to do, where to start? within the C Programming forums, part of the General Programming Boards category; I'm supposed to do all these functions but i'm not sure how to do the printing of k-th digit C ...

1. ## Round double value x to i signifcant decimal places

I'm supposed to do all these functions but i'm not sure how to do the printing of k-th digit

C Ch [Character Case Change ]
Change character Ch to uppercase and print it out
c Ch [Character Case Change]
Change character Ch to lowercase and print it out
P i k [Print k-th Digit ]
Print out the k-th digit of integer i
R x i [Round Reals ]
Round double value x to i signi cant decimal places
S x [Separate ]
Separate out the sign, integer part and fractional
part of double value x
D i x [Partition Integer ]
Given integers i and x, print out two integers j and k,
where the sum of j and k equals i, and when you take x%
of i and truncate it you get j

help?

Code:
```BC
+ -3 4
+ -4 -71
- -41 -7
H
* 3 -5
/ 141 13
/ 14 -3
H
c F
C f
P 2143 3
R 3.1415 2
R 3.1415 3
R 0.01015678 6
H
S -3.1415
S 31.415
D 9 40
D 10 40
D 90 90
Q
c F
C f
H```
so far this is what i have
Code:
```#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define FILENAME "CommandProj2(1).dat"

int main(void) {
char operate, char_change;
double i, j;
FILE *file_in;

file_in = fopen(FILENAME, "r");
if (file_in == NULL)
printf("Error opening input file. \n");
else
{
fscanf(file_in, "%c %c", &operate, &char_change);
if (operate == 'c')
printf("%c", toupper(char_change));
else if (operate == 'C')
printf("%c", tolower(char_change));
else if (operate == 'P')
printf("");
else if (operate == "R")
printf("");
else if (operate == "S")
printf("");
else if (operate == "D")
printf("");

}

return 0;
}```

2. Originally Posted by jackellyn
the printing of k-th digit

P i k [Print k-th Digit ]
Print out the k-th digit of integer i
1st you want to put integer i into a string, use sprintf(). Then you extract the k-th digit...

Code:
```#include <stdio.h>

int main(int argc, const char *argv[]) {
int eg = 1234;
char str[5];

sprintf(str, "%d", eg);

printf("3rd digit of %d = %c\n", eg, str[2]);

return 0;
}```