Zgjidhja e Ushtrimeve te Leksionit 8

Një zgjidhje e ushtrimeve të leksionit 8 :

Ushtrimi 1 :

#include <conio.h>
#include <stdio.h>
void radian(float rad, int &grad, int &min, int &sek){
printf(“Jepni masen e kendit ne radiane: “);
scanf(“%f”,&rad);
sek=rad*648000/3.14;
min=sek/60;
sek=sek-min*60;
grad=min/60;
min=min-grad*60;
printf(“%d grade,%d min,%d sek”,grad,min,sek);
}
int main () {
float rad;
int grad,min,sek;
radian(rad,grad,min,sek);
getch ();
return 0;
}

____________________________________________

Ushtrimi 2 :

#include <conio.h>
#include <stdio.h>
#include <math.h>
void shuma(float s, int n){
printf(“Jepni numrin n : “);
scanf(“%d”,&n);
int i;
s=0;
while(i<=n){
s=s-pow(-1,i)*1/i;
i++;
}
printf(“Shuma eshte %.2f.”,s);
}
int main () {
int n;
float s;
shuma(s,n);
getch ();
return 0;
}
____________________________________________

Ushtrimi 3 :

#include<stdio.h>
#include<conio.h>
void funksion(int a){
int sh=0,min=999,max=-999;
while(a!=999){
printf(“Jep numrin,fut numrin 999 ne fund te detyres : “);
scanf(“%d”,&a);
if(a!=999){
sh+=a;
if(a<min)min=a;
if(a>max)max=a;
}
}
printf(“Shuma eshte %d.\n”,sh);
printf(“Numri me i madh eshte %d.\n”,max);
printf(“Numri me i vogel eshte %d.”,min);
}
int main(){
int a;
funksion(a);
getch ();
return 0;
}
____________________________________________

Ushtrimi 4 :

#include<stdio.h>
#include<conio.h>
#include<math.h>
void funksion(float a,float b,float c){
printf(“Jep koeficentet e ekuacionit (a,b,c) : “);
scanf(“%f%f%f”,&a,&b,&c);
float dallori,x,x1,x2;
dallori=b*b-4*a*c;
if(dallori>0){
x1=(-b+sqrt(dallori))/2*a;
x2=(-b-sqrt(dallori))/2*a;
printf(“Ekuacioni ka dy rrenje.\nx1=%.2f,x2=%.2f.”,x1,x2);
}
if(dallori==0){
x=-b/2*a;
printf(“Ekuacioni ka nje rrenje.\nx=%.2f.”,x);
}
if(dallori<0)printf(“Ekuacioni nuk ka zgjidhje.”);
}
int main(){
int a,b,c;
funksion(a,b,c);
getch ();
return 0;
}
____________________________________________

Studime të mbara!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: