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();
}
@raziyevburhan
Copy link

#include <stdio.h>
#include <stdlib.h>
int main()
{
int vec_len,src=0;
scanf("%d",&vec_len);
int vec1[vec_len],vec2[vec_len];
for(int i = 0; i < vec_len; i++)
{
scanf("%d",&vec1[i]);
scanf("%d",&vec2[i]);
}
for(int i = 0; i < vec_len; i++)
{
src = src+ vec1[i]*vec2[i];
}
printf("%d",src);
return 0;
}

@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