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 8ca6e918a10fb718721881af2619812032416989 Mon Sep 17 00:00:00 2001 From: msisandeepdas <44505976+msisandeepdas@users.noreply.github.com> Date: Fri, 26 Oct 2018 21:59:10 +0530 Subject: [PATCH 3/3] Update Basic_14.c --- Basic_14.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Basic_14.c b/Basic_14.c index 2583b26..8dbe4f1 100644 --- a/Basic_14.c +++ b/Basic_14.c @@ -1,3 +1,33 @@ // TASK // Write code to find the average of the elements in an array // Code Below + +#include + +int main() +{ + int n, i; + float num[100], sum = 0.0, average; + + printf("Enter the numbers of elements: "); + scanf("%d", &n); + + while (n > 100 || n <= 0) + { + printf("Error! number should in range of (1 to 100).\n"); + printf("Enter the number again: "); + scanf("%d", &n); + } + + for(i = 0; i < n; ++i) + { + printf("%d. Enter number: ", i+1); + scanf("%f", &num[i]); + sum += num[i]; + } + + average = sum / n; + printf("Average = %.2f", average); + + return 0; +}