Zgjidhja e Ushtrimeve te Leksionit 11

Një zgjidhje e ushtrimeve të leksionit 11 :

Ushtrimi 1:

#include<stdio.h>
#include<conio.h>
struct student{
char emri[20];
int numri;
char lenda[20];
float nota;
};
int main(){
struct student s;
printf(“Jep informacionin per studentin : \n\n”);
printf(“Fut emrin : “);
scanf(“%s”,s.emri);
printf(“Fut numrin qe studenti ka ne rregjister : “);
scanf(“%d”,&s.numri);
printf(“Fut lenden : “);
scanf(“%s”,&s.lenda);
printf(“Fut noten : “);
scanf(“%f”,&s.nota);
printf(“\n\nTe dhenat e futura jane : \n\n”);
printf(“Emri i studentit : %s\n”,s.emri);
printf(“Numri ne rregjister : %d\n”,s.numri);
printf(“Lenda e provimit : %s\n”,s.lenda);
printf(“Nota : %.2f\n”,s.nota);
getch();
return 0;
}
____________________________________

Ushtrimi 2:

#include<stdio.h>
#include<conio.h>
int main(){
struct kompleks{
float real;
float imag;
}kompleksi;
kompleks n1,n2,temp;
printf(“Per numrin e pare kompleks : \n”);
printf(“Jep njesine reale te numrit : “);
scanf(“%f”,&n1.real);
printf(“Jep njesine imagjinare te numrit : “);
scanf(“%f”,&n1.imag);
printf(“\nPer numrin e dyte kompleks : \n”);
printf(“Jep njesine reale te numrit : “);
scanf(“%f”,&n2.real);
printf(“Jep njesine imagjinare te numrit : “);
scanf(“%f”,&n2.imag);
temp.real=n1.real+n2.real;
temp.imag=n1.imag+n2.imag;
printf(“\n\nShuma e dy numrave kompleks eshte %.1f+%.1fi”,temp.real,temp.imag);
getch();
return 0;
}
____________________________________

Ushtrimi 3 :

#include<stdio.h>
#include<conio.h>
struct koha{
int sekonda;
int minuta;
int ore;
};
int main(){
struct koha k1,k2,diferenca;
printf(“Fut fillimin e kohes : \n”);
printf(“Fut oren,minutat dhe sekondat : “);
scanf(“%d%d%d”,&k1.ore,&k1.minuta,&k1.sekonda);
printf(“Fut kohen e perfundimit : \n”);
printf(“Fut oren,minutat dhe sekondat : “);
scanf(“%d%d%d”,&k2.ore,&k2.minuta,&k2.sekonda);
if(k2.sekonda>k1.sekonda){
–k1.minuta;
k1.sekonda+=60;
}
diferenca.sekonda=k1.sekonda-k2.sekonda;
if(k2.minuta>k1.minuta){
–k1.ore;
k1.minuta+=60;
}
diferenca.minuta=k1.minuta-k2.minuta;
diferenca.ore=k1.ore-k2.ore;
printf(“\nTIME DIFFERENCE: %d:%d:%d – %d:%d:%d = %d:%d:%d”,k1.ore,k1.minuta,k1.sekonda,k2.ore,k2.minuta,k2.sekonda,diferenca.ore,diferenca.minuta,diferenca.sekonda);
getch();
return 0;
}

____________________________________

Ushtrimi 4 :

#include<stdio.h>
#include<conio.h>
struct student{
char emri[20];
int numri;
char lenda[20];
float nota;
};
int main(){
int i,n;
printf(“Jep numrin e studenteve : “);
scanf(“%d”,&n);
struct student s[n];
for(int i=0;i<n;i++){
printf(“\nJep informacionin per studentin %d : \n\n”,i+1);
printf(“Fut emrin : “);
scanf(“%s”,s[i].emri);
printf(“Fut numrin qe studenti ka ne rregjister : “);
scanf(“%d”,&s[i].numri);
printf(“Fut lenden : “);
scanf(“%s”,&s[i].lenda);
printf(“Fut noten : “);
scanf(“%f”,&s[i].nota);
}
for(int i=0;i<n;i++){
printf(“\n\nTe dhenat e futura jane : \n\n”);
printf(“Emri i studentit %d : %s\n”,i+1,s[i].emri);
printf(“Numri ne rregjister : %d\n”,s[i].numri);
printf(“Lenda e provimit : %s\n”,s[i].lenda);
printf(“Nota : %.2f\n”,s[i].nota);
}
getch();
return 0;
}

____________________________________

Ushtrimi 5 :

#include<stdio.h>
#include<conio.h>
struct student{
char emri[20];
float nota;
};
int main(){
int i,n,max=0,poz;
printf(“Jep numrin e studenteve : “);
scanf(“%d”,&n);
struct student s[n];
for(int i=0;i<n;i++){
printf(“\nJep informacionin per studentin %d : \n\n”,i+1);
printf(“Fut emrin : “);
scanf(“%s”,s[i].emri);
printf(“Fut noten : “);
scanf(“%f”,&s[i].nota);
}
for(int i=0;i<n;i++){
if(s[i].nota>max){
max=s[i].nota;
poz=i;
}
}
printf(“Studenti me note me te larte eshte %s.”,s[poz].emri);
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: