Zgjidhja e Ushtrimeve te Leksionit 6

Një zgjidhje e ushtrimeve të leksionit 6 :

Ushtrimi 1 :

#include <stdio.h>
#include <conio.h>
int main(){
int i,sh=0,shk,n;
printf(“Jep shumen:”);
scanf(“%d”,&shk);
printf(“Jep numrin n:”);
scanf(“%d”,&n);
for(i=1;i<=n;i++){
if(sh>=shk)break;
sh=sh+i;
}
printf(“Shuma eshte %d.\nArrihet me mbledhjen e %d numrave.”,sh,i);
getch ();
return 0;
}

____________________________________________

Ushtrimi 2 :

#include <stdio.h>
#include <conio.h>
int main(){
int i,num,prodhimi=1;
for(i=1;i<=4;i++){
printf(“Numri %d:”,i);
scanf(“%d”,&num);
if(num==0)continue;
prodhimi=prodhimi*num;
}
printf(“Prodhimi=%d”,prodhimi);
getch ();
return 0;
}

____________________________________________

Ushtrimi 3 :

#include<stdio.h>
#include<conio.h>
int main(){
int muaji;
printf(“Jep muajin : “);
scanf(“%d”,&muaji);
switch (muaji){
case 12:
case 1:
case 2:
printf(“Muaji eshte muaj dimri.”);
break;
case 3:
case 4:
case 5:
printf(“Muaji eshte muaj pranvere.”);
break;
case 6:
case 7:
case 8:
printf(“Muaji eshte muaj vere.”);
break;
case 9:
case 10:
case 11:
printf(“Muaji eshte muaj vjeshte.”);
break;
default:
printf(“Te dhenat u futen ne menyre te gabuar.”);

}
getch();
return 0;
}

____________________________________________

Ushtrimi 4 :

#include<stdio.h>
#include<conio.h>
int main()
{
int n1,n2,shuma,diferenca,prodhimi;
float heresi;
char v;
printf(“Fut veprimin : “);
scanf(“%c”, &v);
printf(“Fut numrin e pare : “);
scanf(“%d”, &n1);
printf(“Fut numrin e dyte : “);
scanf(“%d”, &n2);

switch (v)
{
case ‘+’ :
shuma=n1+n2;
printf(“Shuma eshte %d.”,shuma);
break;
case ‘-‘ :
diferenca=n1-n2;
printf(“Diferenca eshte %d.”,diferenca);
break;
case ‘*’ :
prodhimi=n1*n2;
printf(“Prodhimi eshte %d.”,prodhimi);
break;
case ‘/’ :
heresi=n1/n2;
printf(“Heresi eshte %.2f.”,heresi);
break;
default:
printf(“Te dhenat u futen ne menyre te gabuar.”);

}
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: