Tell me how to add colors.

closed account (oy721hU5)
Hello fellow programmers,

I have started to program in C, just recently. Do any of you guys know how to add colors to the lines. I would like to do this to make my code look more than just black and white.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main()
{

    system("cls");

    int A, B, C, D, E;

    A = 1;
    B = 2;
    C = 3;
    D = 4;
    E = 5;


    printf("\n\n\t     The value of (AA+BB)/(CC+DD)                 = %10d",  ((A*A + B*B)/(C*C + D*D)),         "\n" );
    printf("\n\n\t     The value of (AA + BB - CC)/(2AB)            = %10d",  (A*A + B*B - C*C)/(2*A*B),         "\n" );
    printf("\n\n\t     The value of (A(B-C)(C-D)(D-E))/(A+B+C+D+E)  = %10d",  (A*(B-C)*(C-D)*(D-E))/(A+B+C+D+E), "\n" );
    printf("\n\n\t     The value of (A^3 - B^3)/(C^3 + D^3)         = %10d",  (A*A*A - B*B*B)/(C*C*C + D*D*D),   "\n" );

    printf("\n\n\n\n\n\n\n");


}
closed account (Dy7SLyTq)
what os are you you running? and i dont think , ((A*A + B*B)/(C*C + D*D)), "\n" will work
closed account (oy721hU5)
Windows 7. I am using code::blocks to compile and run and it works well.
The reason why ((A*A + B*B)/(C*C + D*D)) doesn't work is because it evaluates to 5 / 25. Since they are integers the division equals to 0 with a remainder of 25.
closed account (Dy7SLyTq)
i was more talking about the "\n" at the end, because if i remember right thats not how printf works
In this case the "\n" is likely to just be ignored by printf. Some implementations may warn that the number of arguments don't match the number of specifiers in the format string.
closed account (Dy7SLyTq)
i know that it would compile, because its just being passed to the ..., but i wanted to bring that to his attention
Topic archived. No new replies allowed.