Skip to content

Instantly share code, notes, and snippets.

@gokhanyavas
Created April 4, 2013 07:26
Show Gist options
  • Save gokhanyavas/5308504 to your computer and use it in GitHub Desktop.
Save gokhanyavas/5308504 to your computer and use it in GitHub Desktop.
Dışarıdan girilen N boyutlu A ve B vektörlerinin skaler çarpımını hesaplayan c program.
#include <stdio.h>
#include <conio.h>
int main ()
{
int i,n,sc;
int a[100],b[100];
printf("Dizilerin eleman sayısını giriniz..:");
scanf("%d",&n);
printf("A dizisini giriniz\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("B dizisini giriniz\n");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
sc=0;
for(i=0;i<n;i++)
sc=sc+a[i]*b[i];
printf("Toplam=%d",sc);
getch();
}
@aabdurrahmanevik
Copy link

#include<stdio.h>

int main()
{
int elemansay , i , toplam = 0 ;
printf("Dizinizin kac elemanli olacak: ");
scanf("%d",&elemansay);
int A_dizi[elemansay],B_dizi[elemansay] ,C_dizi[elemansay];

for(i = 0 ; i < elemansay ; i++)
{
	printf("A dizinizin %d.elemanini giriniz: ",i+1);
	scanf("%d",&A_dizi[i]);
}

printf("\n\n");

for(i = 0; i < elemansay ; i++)
{
	printf("B dizinizin %d.elemanini giriniz: ",i+1);
	scanf("%d",&B_dizi[i]);
}

printf("\n\n");

for (i = 0 ; i < elemansay ; i++)
{
	C_dizi[i] = A_dizi[i] * B_dizi[i];
}

printf("\n\n");

for (i = 0 ; i < elemansay ; i++)
{
	printf("\n%d.eleman: %d",i+1,C_dizi[i]);
}
printf("\n\n");

for(i= 0; i < elemansay; i++)
{
	toplam = toplam + C_dizi[i];
}
printf("Toplam: %d",toplam);





return 0;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment