segunda-feira, 10 de dezembro de 2012

Quadrado dos Números Digitados

Quadrado dos Números Digitados é um programa simples, onde visa mostra aos iniciantes em linguagem C, como armazenar valores num vetor, imprimir estes valores digitados, e imprimir o quadrado dos números armazenados neste vetor.
 Eis a saída deste programa no cmd:


#include <stdio.h>
#include <conio2.h>
float vet [5];
int  main(){
    system ("title QUADRADO DOS NUMEROS DIGITADOS");
    int  p, i = 0;
    textcolor(LIGHTRED);gotoxy(29,2);printf("QUADRADO DOS NUMEROS DIGITADOS");
    textcolor(LIGHTBLUE);gotoxy(29,4);printf("QUANTOS NUMEROS VAI DIGITAR ?  ");
    textcolor(LIGHTRED);scanf("%d", &p);fflush(stdin);
    for(i = 0; i <= p; i++){
        system("cls");
        textcolor(LIGHTRED);gotoxy(27,2);printf("QUADRADO DOS NUMEROS DIGITADOS");
        textcolor(LIGHTBLUE);gotoxy(32,4);printf("DIGITE O");
        textcolor(LIGHTRED);gotoxy(40,4);printf(" %do", i);
        textcolor(LIGHTBLUE);gotoxy(44,4);printf("NUMERO : ");
        textcolor(LIGHTRED); scanf("%f",&vet[i]);fflush(stdin);
    }
    system("cls");
    textcolor(LIGHTRED);gotoxy(27,2);printf("QUADRADO DOS NUMEROS DIGITADOS");
    textcolor(LIGHTBLUE);gotoxy(33,4);printf("sa_sp10@hotmail.com");
    textcolor(LIGHTGREEN);gotoxy(30,6);printf("OS VALORES DIGITADOS FORAM ");
    textcolor(YELLOW);for(i = 0; i <= p; i++){
        textcolor(YELLOW); gotoxy(33,i + 8);printf("NUMERO  ");
        textcolor(LIGHTRED);gotoxy(83,i + 8); printf("[%d] = %.1f", i, vet [i] );
    }
    getche();
    textcolor(LIGHTGREEN);gotoxy(30,15);printf("O QUADRADO DOS NUMEROS SAO");
    textcolor(YELLOW);for(i = 0; i <= p; i++){
        textcolor(YELLOW); gotoxy(33,i + 17);printf("NUMERO  ");
        textcolor(LIGHTRED);gotoxy(83,i + 17); printf("[%d] = %.1f", i, vet [i] * vet [i]);
    }
    textcolor(LIGHTRED);gotoxy(35,i + 19);printf("O ROCCO AGRADECE");
    getche();
}

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.