Last active
June 15, 2023 07:19
-
-
Save gokhanyavas/5267053 to your computer and use it in GitHub Desktop.
Çarpma işlemini kullanmadan iki sayının çarpımını bulan c programı
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//çarpma işlemini kullanmadan iki sayının çarpımını bulan program | |
#include <stdio.h> | |
#include <conio.h> | |
int main() | |
{ | |
// while(1) // sonsuz döngü | |
// %g virgülden sonraki sıfırları göstermiyor | |
int a,b,s,i; | |
printf("Lütfen 1.sayıyı giriniz : \n"); | |
scanf("%d",&a); | |
printf("Lütfen 2.sayıyı giriniz : \n"); | |
scanf("%d",&b); | |
s= 0; | |
for (i=1; i<=a; i++ ) | |
s= s+b; | |
printf("%d * %d = %d", a,b,s); | |
getch(); | |
// ekranın kapanmasını engelliyor.. | |
} | |
for döngüsünün önünde ; var
Gökhan hocam, programda bir hata var çarpma işlemini direk 'b' ye eşitliyor. For döngüsünden sonra ; koymuşsunuz. Çalışmıyor onun için.
for döngüsünün önünde ; var
şu an bir problem gözükmüyor.
#include <stdio.h>
#include <conio.h>
int main() {
float a,b,c=0.0;
int i;
printf("Hesap Makinesi Carpma:\n\n");
printf("1. Sayiyi giriniz:");
scanf("%f",&a);
printf("2. Sayiyi giriniz:");
scanf("%f",&b);
for (i=1;i<=b;i++) {
c +=a;
}
printf("Sonuc=%.2f",c);
getch();
return 0;
}
Teşekkür ederim:)
14 Ağu 2020 Cum 15:47 tarihinde Emircanf <notifications@github.com> şunu
yazdı:
… ***@***.**** commented on this gist.
------------------------------
#include <stdio.h>
#include <conio.h>
int main() {
float a,b,c=0.0;
int i;
printf("Hesap Makinesi Carpma:\n\n");
printf("1. Sayiyi giriniz:");
scanf("%f",&a);
printf("2. Sayiyi giriniz:");
scanf("%f",&b);
for (i=1;i<=b;i++) {
c +=a;
}
printf("Sonuc=%.2f",c);
getch();
return 0;
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/5267053#gistcomment-3417447>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALQ2VN4GJO3B46XOHNZYU3LSAUW7NANCNFSM4JPYLM2A>
.
Negatif sayıları da dahil ederek yazmış olduğum kod ...
//Çarpma işlemini kullanmadan iki sayının çarpımını bulan c programı.
#include <stdio.h>
#include <conio.h>
#include <locale.h>
int carpim (int a,int b)
{
int sonuc=0,i=0;
if(a>=0)
{
for( ;i<a;i++)
{
sonuc+=b;
}
}
if(a<0)
{
for( ;i>a;i--)
{
sonuc-=b;
}
}
return sonuc;
}
int main()
{
setlocale(LC_ALL, "Turkish");
int sayi1,sayi2;
printf("Çarpmak istediğiniz ilk sayıyı giriniz = ");scanf("%d",&sayi1);
printf("Çarpmak istediğiniz ikinci sayıyı giriniz = ");scanf("%d",&sayi2);
printf("Girdiğiniz sayıların çarpımı = %d",carpim(sayi1,sayi2));
getch();
return 0;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gökhan hocam, programda bir hata var çarpma işlemini direk 'b' ye eşitliyor. For döngüsünden sonra ; koymuşsunuz. Çalışmıyor onun için.