From 6a2dff9cf3099edfcd5706c7573dd0d63d2c3dae Mon Sep 17 00:00:00 2001 From: njain794 <44344547+njain794@users.noreply.github.com> Date: Fri, 26 Oct 2018 21:20:09 +0530 Subject: [PATCH 1/3] Update Basic_1.c code in c language - whether a no. is even or odd --- Basic_1.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Basic_1.c b/Basic_1.c index 5f89310..72aabe1 100644 --- a/Basic_1.c +++ b/Basic_1.c @@ -1,3 +1,21 @@ // TASK // Write code to find if the number is even or odd // Code Below +#include +#include +void main() +{ + clrscr(); + int a,b,c; + printf("enter the no. to find out whether it is even or odd"); + scanf("%d",&a); + if(a%2==0) + { + printf("no. is even"); + } + else + { + printf("no. is odd"0); + } + getch(); +} From e7b2cd1cbd54f7e2006df861f8842c1396e0907a Mon Sep 17 00:00:00 2001 From: njain794 <44344547+njain794@users.noreply.github.com> Date: Fri, 26 Oct 2018 21:25:26 +0530 Subject: [PATCH 2/3] Update Basic_12.c code to find cube of a no. in c languge --- Basic_12.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Basic_12.c b/Basic_12.c index 81bcbae..4227168 100644 --- a/Basic_12.c +++ b/Basic_12.c @@ -1,3 +1,15 @@ // TASK // Write code to find cube of a number // Code Below +#include +#include +void main() +{ + clrscr(); + int a,b=0,c; + printf("enter the no to take out its cube = "); + scanf("%d",&a); + b=a*a*a; + printf("cube of no. is = %d",b); + getch(); +} From 457ce15abd6f8af8228d326fa2d8bb74bc694352 Mon Sep 17 00:00:00 2001 From: msisandeepdas <44505976+msisandeepdas@users.noreply.github.com> Date: Fri, 26 Oct 2018 22:26:13 +0530 Subject: [PATCH 3/3] Update Basic_9.c --- Basic_9.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Basic_9.c b/Basic_9.c index 84497d5..ca9c302 100644 --- a/Basic_9.c +++ b/Basic_9.c @@ -1,3 +1,67 @@ // TASK // Write code to add 2 3D Matrix // Code Below + +#include +#define MAX 20 + + +void readArray(int a[],int size) +{ + int i; + for(i=0;i< size;i++) + { + printf("Enter %d element :",i+1); + scanf("%d",&a[i]); + } +} + +void printArray(int a[],int size) +{ + int i; + for(i=0;i < size; i++) + printf("%5d",a[i]); +} + +void addArray(int a[],int b[],int c[],int size) +{ + int i; + for(i=0; i< size;i++) + c[i]=a[i]+b[i]; +} + +void subArray(int a[],int b[],int c[],int size) +{ + int i; + for(i=0; i< size;i++) + c[i]=a[i]-b[i]; +} + +int main() +{ + int A[MAX],B[MAX],ADD[MAX],SUB[MAX]; + int i,n; + + + printf("\nEnter size of an Array :"); + scanf("%d",&n); + + printf("\nEnter elements of Array 1:\n"); + readArray(A,n); + printf("\nEnter elements of Array 2:\n"); + readArray(B,n); + + /* add Arrays*/ + addArray(A,B,ADD,n); + /* subtract two Arrays*/ + subArray(A,B,SUB,n); + + printf("\nArray elements after adding :\n"); + printArray(ADD,n); + + printf("\nArray elements after subtracting :\n"); + printArray(SUB,n); + + printf("\n\n"); + return 0; +}