How to put color in text

Asked

Viewed 70 times

0

This is the statement: In a college, students with an average of at least 7.0 pass, students with an average of less than 3.0 fail, and others are recovery. Given the two notes of a student, prepare a program in C that inform your situation. Use the colors blue, red and yellow for messages "approved", "failed" and "recovery", respectively.

The logic I managed to do less the part of putting the color. Thank you from now!!

#include <stdio.h>
#include <conio.h>
int main (){

float n1,n2,media;
printf ("Digite a primeira nota:");
scanf ("%f",&n1);
printf ("Digite a segunda nota:");
scanf ("%f",&n2);

media = (n1+n2)/2;

if (media>=7)
printf ("APROVADO");

else{

if (media <3)

printf ("REPROVADO");

else{
    
    if (media >=3)
    printf ("RECUPERACAO");
}
}
}
  • https://answall.com/questions/157898/como-destacar-texto-mudar-cor-em-c-ansi

1 answer

2

It is possible to put the color in the elements as follows, for the color red, yellow and blue just put the following functions:

//vermelho
printf("\33[1;31m");
printf("Hello World");
//azul
printf("\33[1;34m");
printf("Hello World");
//amarelo
printf("\33[0;33m");
printf("Hello World");

To print these colors I used this link, that you can use for consultation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.