diff --git a/4a.txt b/4a.txt new file mode 100644 index 0000000..d91ed9b --- /dev/null +++ b/4a.txt @@ -0,0 +1,37 @@ +#include //preprocessor +void addarrays(int X[],int Y[],int size);//function declaration +int main()//main function +{ + int A[5],B[5],C=5,i;//Array and variable declaration + printf("Enter the entries of an array A:\n");//outputs the statement in the quotes to the console + for(i=0;i<5;i++)//for loop for an array A + { + scanf("%d",&A[i]);//gets the values of array A from the keyboard + } + printf("\n"); + + printf("Enter the entries of an array B:\n");//outputs the statement in the quotes to the console + for(i=0;i<5;i++)//for loop for an array B + { + scanf("%d",&B[i]);//gets the values of array B from the keyboard + } + printf("\n"); + addarrays(A,B,C);//Function call + + return 0; +} +void addarrays(int X[],int Y[],int size)//Function header +{ + int counter,C[size];//declaration of the local variables in the function definition + for(counter=0;counter//preprocessor +#include//preprocessor +void addarrays(int X[],int Y[],int size);//function declaration +int main()//main function +{ + int A[5],B[5],C=5,i;//Array and variable declaration + printf("Enter the entries of an array A:\n");//outputs the statement in the quotes to the console + for(i=0;i<5;i++)//for loop for an array A + { + scanf("%d",&A[i]);//gets the values of array A from the keyboard + } + printf("\n");//prints a new line + + printf("Enter the entries of an array B:\n");//outputs the statement in the quotes to the console + for(i=0;i<5;i++)//for loop for an array B + { + scanf("%d",&B[i]);//gets the values of array B from the keyboard + } + printf("\n"); + addarrays(A,B,C);//Function call + getch(); + + return 0;//Terminates the main function and returns zero +} +void addarrays(int X[],int Y[],int size)//Function header +{ + int counter,*ptr[size],C[size];//declaration of the local variables in the function definition + printf("Values of array A:\n"); + for(counter=0;counter<5;counter++)//for loop for printing the output of the third array to the screen + { + printf("%d ",X[counter]);//prints the values of the first array to the screen + } + printf("\n\n");//prints a new line + + printf("Values of array B:\n"); + for(counter=0;counter<5;counter++)//for loop for printing the output of the third array to the screen + { + printf("%d ",Y[counter]);//prints the values of the second array to the screen + } + printf("\n\n");//prints a new line + + for(counter=0;counter +int x=1; /*variable is declared before the main() function */ +main() +{ + if(x==1)/*the if statement is not meant to be terminated and use of assignment operator instead of relational operator*/ + printf("x equals 1"); + else /*the if-else syntax was wrong, it cannot be if-otherwise*/ + { + printf("x does not equal 1"); + } +