Last active
August 19, 2018 19:41
-
-
Save mesaque/35ec8c5e529751e957ef1300967b1f09 to your computer and use it in GitHub Desktop.
fael progamacao estruturada
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
author:mesaque | |
date: 08/2018 | |
*/ | |
//Exercise 1: | |
#include <cstdio> /* printf, scanf */ | |
#include <cstdlib> /* srand, rand */ | |
int main() | |
{ | |
int Ntermos, termos[1][2], n, p, i =0; | |
printf("Insira o numero de termos(maximo de 3): "); | |
scanf("%d", &Ntermos); | |
static int Ntermo = Ntermos; | |
for(int loop=0; loop < Ntermo; loop++ ) | |
{ | |
printf("Insira o numerador do [%d] termo: ", i); | |
scanf("%d", &n); | |
termos[i][0] = n; | |
printf("Insira o denominador do [%d] termo: ", i); | |
scanf("%d", &p); | |
termos[i][1] = p; | |
i++; | |
} | |
int k =0; | |
while( k < Ntermo ) | |
{ | |
printf("%d", termos[k][0] ); | |
printf("\t"); | |
k++; | |
} | |
printf("\n"); | |
int l =0; | |
while( l < Ntermo ) | |
{ | |
printf("----"); | |
printf("\t"); | |
l++; | |
} | |
printf("\n"); | |
int u = 0; | |
while( u < Ntermo ) | |
{ | |
printf("%d", termos[u][1] ); | |
printf("\t"); | |
u++; | |
} | |
int x = 0; | |
int divisao[1]; | |
while( x < Ntermo ) | |
{ | |
divisao[x] = (termos[x][0] / termos[x][1]) ; | |
x++; | |
} | |
int z =0; | |
int soma = 0; | |
while( z < Ntermo ) | |
{ | |
soma += divisao[z]; | |
z++; | |
} | |
printf("s=%d", soma ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment