English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have to do a program wherein it is necessary to align the data. it's like a table but without the lines. is there any function in c that will allow me to print in a particular value in a specified row and column area? using tabs wouldn't work because the data values have varying lengths thus ending up unaligned.

2006-08-22 02:21:21 · 4 answers · asked by andy 2 in Computers & Internet Programming & Design

4 answers

Yea you can do it by using %+d and %-d. Just use them and see what happens.

2006-08-25 17:37:19 · answer #1 · answered by shuvamchatterjee 3 · 0 0

There are quite a few strategies the for loop is the most common with you basically incrementing through 2 and printing the numbers that are unusual as all unusual numbers are 2 aside, nevertheless there are different strategies to do loops in C. The at the same time as loop int i =a million; /* this instruments the volume to a million */ at the same time as ( i <= 40 9) /* If the volume is below or equivalent to 40 9 the loop will proceed */ { /* begining of loop */ printf("%d ",i); /* this prints the volume the first is the volume a million*/ i+=2; /* Now upload 2 to the volume */ /*the loop will bypass decrease back to the initiating */ } /* end of loop */ the subsequent one is the do at the same time as loop no longer so regularly used yet nevertheless a valid loop int i =a million; /* the variable i is initialised to a million*/ do /* commence of loop */ { printf("%d ",i); i=i+2; /* This increments through 2 or you should use i+=2; they're an same */ } at the same time as ( i <= 40 9) /* this tests the fee no matter if that is below 40 9 it is going decrease back to a loop */ Then there is the recursive - it really is once you create a function that calls it really is self slightly cleverer version int count_odd(int x); /* predeclaration of function */ int major() { int x = a million; int volume; volume =count_odd(x); printf( go back 0; } /* it really is the function which returns a fee */ int count_odd(int x) { /* this instruments the reduce to 40 9 so if the fee is an same as 40 9 it would not call it really is self*/ if (x == 40 9 ) go back 0; else { /* prints the fee of x */ printf( "%d " , x); /* the function now calls on it really is self yet promises 2 the fee */ go back count_odd(x + 2); }

2016-11-26 22:47:43 · answer #2 · answered by yancy 4 · 0 0

Formatting the output can be done directly within that "%f %s \n..." portion, %.2f means output by 2 decimal places, but i really don't recall much from those, more than that you may need to create some intermediate string manipulation code to achieve what you want.

2006-08-22 02:35:13 · answer #3 · answered by Andy T 7 · 0 1

You mean formatted output in c?
chek this or similar links maybe
http://www-ccs.ucsd.edu/c/lib_prin.html

2006-08-22 02:28:31 · answer #4 · answered by Neil 5 · 0 0

fedest.com, questions and answers