Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Basic_8.c #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Basic_1.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// TASK
// Write code to find if the number is even or odd
// Code Below
#include<stdio.h>
#include<conio.h>
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();
}
12 changes: 12 additions & 0 deletions Basic_12.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// TASK
// Write code to find cube of a number
// Code Below
#include<stdio.h>
#include<conio.h>
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();
}
52 changes: 52 additions & 0 deletions Basic_8.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
// TASK
// Write code to add two 2D Matrix
// Code Below

#include <stdio.h>
int main(){
int r, c, a[100][100], b[100][100], sum[100][100], i, j;

printf("Enter number of rows (between 1 and 100): ");
scanf("%d", &r);
printf("Enter number of columns (between 1 and 100): ");
scanf("%d", &c);

printf("\nEnter elements of 1st matrix:\n");

for(i=0; i<r; ++i)
for(j=0; j<c; ++j)
{
printf("Enter element a%d%d: ",i+1,j+1);
scanf("%d",&a[i][j]);
}

printf("Enter elements of 2nd matrix:\n");
for(i=0; i<r; ++i)
for(j=0; j<c; ++j)
{
printf("Enter element a%d%d: ",i+1, j+1);
scanf("%d", &b[i][j]);
}

// Adding Two matrices

for(i=0;i<r;++i)
for(j=0;j<c;++j)
{
sum[i][j]=a[i][j]+b[i][j];
}

// Displaying the result
printf("\nSum of two matrix is: \n\n");

for(i=0;i<r;++i)
for(j=0;j<c;++j)
{

printf("%d ",sum[i][j]);

if(j==c-1)
{
printf("\n\n");
}
}

return 0;
}