sábado, 22 de dezembro de 2012

Programa Multiplicacao em Vetor

Este Programa mostra como executar multiplicações em vetor,
as multiplicações são de  vet1 [];
por vet2 []; e os resultados são armazenados em vet3 []; 
Multipliquei também os índices de vet1 []; e de vet2 []; 
e os resultados foram armazenados em vet4 [0]; e vet4 [1]; 
O programa é muito simples e indicado
aos iniciantes em linguagem C.

Eis a saída deste Programa no cmd:


Copie, cole e compile o código abaixo:

#include <stdio.h>

#include <conio2.h>


int main ( ) {

system ( "title PROGRAMA MULTIPLICACAO EM VETOR" );

int i;

int vet1 [ 5 ] = { 1, 2, 3, 4, 5 };

int vet2 [ 5 ] = { 7, 8, 9, 10, 11 };

int vet3 [ 5 ];

int vet4 [ 5 ];

textcolor ( LIGHTRED );

gotoxy ( 29, 3 );

printf ( "PROGRAMA MULTIPLICACAO EM VETOR" );

textcolor ( LIGHTBLUE );

gotoxy ( 23, 5 );

printf ( "ESTE E O VETOR 1 ==>" );

gotoxy ( 49, 5 );

textcolor ( YELLOW );

for ( i = 0; i < 5; i++ ) {

printf ( " %d ", vet1 [ i ] );

}

getche ( );

textcolor ( LIGHTBLUE );

gotoxy ( 23, 7 );

printf ( "ESTE E O VETOR 2 ==>" );

gotoxy ( 49, 7 );

textcolor ( YELLOW );

for ( i = 0; i < 5; i++ ) {

printf ( " %d ", vet2 [ i ] );

}

getche ( );

textcolor ( LIGHTBLUE );

gotoxy ( 8, 9 );

printf ( "ESTE E O VETOR 1 MULTIPLICADO POR ELE MESMO ==>" );

gotoxy ( 57, 9 );

textcolor ( YELLOW );

for ( i = 0; i < 5; i++ ) {

printf ( " %d ", vet1 [ i ] * vet1 [ i ] );

}

getche ( );

textcolor ( LIGHTBLUE );

gotoxy ( 8, 11 );

printf ( "ESTE E O VETOR 2 MULTIPLICADO POR ELE MESMO ==>" );

gotoxy ( 57, 11 );

textcolor ( YELLOW );

for ( i = 0; i < 5; i++ ) {

printf ( " %d ", vet2 [ i ] * vet2 [ i ] );

}

getche ( );

textcolor ( LIGHTGREEN );

gotoxy ( 16, 13 );

printf ( "VETOR 3 E O RESULTADO DO PRODUTO DOS DOIS VETORES " );

textcolor ( YELLOW );

for ( i = 0; i < 5; i++ ) {

vet3 [ i ] = vet1 [ i ] * vet1 [ i ] * vet2 [ i ] * vet2 [ i ];

}

gotoxy ( 30, 15 );

for ( i = 0; i < 5; i++ ) {

vet3 [ i ] = vet1 [ i ] * vet1 [ i ] * vet2 [ i ] * vet2 [ i ];

printf ( " %d ", vet3 [ i ] );

}

getche ( );

i = 0;

textcolor ( LIGHTBLUE );

gotoxy ( 16, 17 );

printf ( "VETOR 4 E A MULTIPLICACAO DOS INDICES DO VETOR 1 E 2" );

vet4 [ 0 ] = vet1 [ 0 ] * vet1 [ 1 ] * vet1 [ 2 ] * vet1 [ 3 ] * vet1 [ 4 ];

gotoxy ( 30, 19 );

textcolor ( YELLOW );

printf ( "VET 4 [%d]: %d", i, vet4 [ 0 ] );

vet4 [ 1 ] = vet2 [ 0 ] * vet2 [ 1 ] * vet2 [ 2 ] * vet2 [ 3 ] * vet2 [ 4 ];

gotoxy ( 30, 21 );

textcolor ( YELLOW );

printf ( "VET 4 [%d]: %d", i + 1, vet4 [ 1 ] );

textcolor ( LIGHTRED );

gotoxy ( 33, 23 );

printf ( "\aMUITO OBRIGADO" );

getche ( );

}


Nenhum comentário:

Postar um comentário

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