Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Pune Laboratori 2

Ushtrim 1: Ndertoni nje program qe percakton nje matrice dy-dimensionale, data[11][5] te


tipit double. Inicializoni elementet e kolones se pare me vlerat nga 2.0 ne 3.0 (duke perfshire dhe
kufijte) qe ndryshojne me shkalle nga 0.1. Nese elementi i pare i nje rreshti ka vleren x, atehere
elementet e tjere te rreshtit duhet te kene vlerat 1/x, x2, x3, dhe x4. Shfaqni si output vlerat e
matrices, ku vlerat e cdo rreshti jane nje nje rresht te vecuar dhe per cdo kolone jepet ne krye
formula perkatese.
Output-i duhet te jete si me poshte:

Ushtrim 2:
Ndertoni nje funksion me emer kthe_mbrapsht qe kthen mbrapsht shifrat e nje numri te plote.
Ndertoni nje funksion me emer shifra_madhe qe kthen shifren me te madhe te nje numri te
plote. (p.sh. nese numri eshte 5322807, funksioni duhet te ktheje 8).

Te ndertohet nje program qe lexon nga perdoruesi nje numer te plote dhe therret dy funksionet e
permendura me siper dhe rezultatet qe ato kthejne per kete numer te lexuar, i printojne ne ekran.

Pune Laboratori 2

/* zgjidhja e ushtrimit 1*/


#include <stdio.h>
#include <conio.h>
int main(void)
{
double data[11][5];
double value = 2.0;
int row = 0;
int col = 0;

/*
/*
/*
/*

Stores data values


*/
Value to be stored in array */
Loop index
*/
Loop index
*/

for(int row = 0 ; row<11 ; row++)


{
data[row][0] = value;
value += 0.1;
}
for(int row = 0 ; row<11 ; row++)
{
data[row][1] = 1.0/data[row][0];
data[row][2] = data[row][0]*data[row][0];
data[row][3] = data[row][2]*data[row][0];
data[row][4] = data[row][3]*data[row][0];
}
printf("\n
printf("
printf("
printf("
printf("

x
");
1/x ");
x*x ");
x*x*x ");
x*x*x*x");

for(int row = 0 ; row<11 ; row++)


{
printf("\n");
for(col = 0 ; col<5 ; col++)
printf("%15.4lf", data[row][col]);
}
printf("\n");
getche();
return 0;
}

/*
/*
/*
/*

1/x
x*x
x*x*x
x*x*x*x

*/
*/
*/
*/

You might also like