Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }
In this C program we will represent a Matrix. The elements or data will be taken from the user. First we input row 1 from left to right then the next row (row 2) and then the next row and so on. Well, in this case we representing a 3 X 3 Matrix, so here is only three rows.
input:
The elements of the Matrix.output:
The formed Matrix.
CODE---->
#include<stdio.h>
int main()
{
int arr_data[3][3],i,j=0,k=1;
for(i=0;i<3;i++)
{
printf("For Row %d\n",k);
for(j=0;j<3;j++)
{
printf("Enter data: ");
scanf("%d",&arr_data[i][j]);
}
k++;
}
printf("\nNow the Matrix is: \n\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf(" %d ",arr_data[i][j]);
printf("\n");
}
return 0;
}
Download the C-Program file of this Program.
RESULT :
For Row 1 Enter data: 10 Enter data: 20 Enter data: 30 For Row 2 Enter data: 40 Enter data: 50 Enter data: 60 For Row 3 Enter data: 70 Enter data: 80 Enter data: 90 Now the Matrix is: 10 20 30 40 50 60 70 80 90 -------------------------------- Process exited after 18.82 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Comments
Post a Comment