Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 5
- int main()
- {
- int A[N];
- int B[N];
- int C[N];
- int D[N];
- unsigned long int ils =0;
- int i;
- srand(time(NULL));
- for(i=0; i<N; ++i){
- A[i] = rand()%100;
- B[i] = rand()%100;
- C[i] = A[i] + B[i];
- D[i] = A[i] * B[i];
- ils += A[i]*B[i];
- }
- printf("Elementy wektoru A:\n");
- for(i=0; i<N; ++i){
- printf("%d ", A[i]);
- }
- printf("\n\nElementy wektoru B:\n");
- for(i=0; i<N; ++i){
- printf("%d ", B[i]);
- }
- printf("\n\nWektor bedacy suma wektorow A i B:\n");
- for(i=0; i<N; ++i){
- printf("%d ", C[i]);
- }
- printf("\n\nWektor bedacy iloczynem wektorow A i B:\n");
- for(i=0; i<N; ++i){
- printf("%d ", D[i]);
- }
- printf("\n\nIloczyn skalarny wektorow A i B wynosi: %lu\n", ils);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement