Zgjidhja e Ushtrimeve te Leksionit 7

Një zgjidhje e ushtrimeve të leksionit 7 :

Ushtrimi 1 :

#include <conio.h>
#include <stdio.h>
int main (){
int nr,sp=-1,sn=0;
while(nr!=999){
printf(“Jepni nje numer,futni numrin 999 ne perfundim te detyres:”);
scanf(“%d”,&nr);
if(nr>=0)sp++;
else sn++;
}
if(sp>sn)printf(“Jane futur me shume numra pozitive!”);
else if(sn>sp)printf(“Jane futur me shume numra negative!”);
else printf(“Sasi e barabarte!”);
getch ();
return 0;
}

____________________________________________

Ushtrimi 2 :

#include <stdio.h>
#include <conio.h>

int main(){
int i,n;
float num,mesatarja,shuma;
printf(“Jep sasine e numrave:”);
scanf(“%d”,&n);
for(i=1;i<=n;++i){
printf(“Vendos numrin %d:”,i);
scanf(“%f”,&num);
shuma=shuma+num;
}
mesatarja=shuma/n;
printf(“Mesatarja=%.2f”,mesatarja);
getch();
return 0;
}

____________________________________________

Ushtrimi 3 :

#include <stdio.h>
#include <conio.h>
int main(){
int i, n,nr,shuma=0;
int nr_madh=0, nr_vogel;
printf(“Jep sasine e numrave :\n”);
scanf(“%d”,&num);
for(i=1;i<=num;++i){
printf(“Numri %d:”,i);
scanf(“%d”,&nr);
if(nr_madh<nr){
nr_madh=nr;}
if(nr_vogel>nr){
nr_vogel=nr; }
shuma=shuma+nr;
}
printf(“\t\t\t\t\tNumri me i madh eshte :%d\n\n”,nr_madh);
printf(“\t\t\t\tNumri me i vogel eshte :%d”,nr_vogel);
printf(“\n\n\t\t\tShuma =%d\n”,shuma);
getch ();
return 0;
}

____________________________________________

Ushtrimi 4 :

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main(){
float a,b,c,dallori,x,x1,x2;
printf(“Jep koeficentin a: “);
scanf(“%f”,&a);
printf(“Jep koeficentin b: “);
scanf(“%f”,&b);
printf(“Jep koeficentin c: “);
scanf(“%f”,&c);
dallori=b*b-a*a*c;
if(dallori>0){
x1=(-b+sqrt(dallori))/(2*a);
x2=(-b-sqrt(dallori))/(2*a);
printf(“Rrenjet jane x1=%.2f,x2=%.2f.”,x1,x2);
}
if(dallori=0){
x=-b/(2*a);
printf(“Ekuacioni ka vetem nje rrenje %f.”,x);
}
else if(dallori<0)printf(“Ekuacioni nuk ka rrenje reale!”);
getch();
return 0;
}
____________________________________________

Studime te 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: