Created
April 4, 2013 07:26
-
-
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.
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
#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(); | |
} |
#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
#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;
}