Professional Documents
Culture Documents
Input:
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
Output: It is a IDENTITY MATRIX
#include <stdio.h>
int main()
{
int a[][];
int i = 0, j = 0, row = 0, col = 0;
printf ("Enter the no of rows and columns in the matrix:\n");
scanf ("%d %d", &row, &col);
printf ("Enter the elements of the matrix\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
gets("%d", a[][]);
}
}
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (i == j || a[i][j] != 1)
{
flag = -1;
break;
}
else if (i != j || a[j][i] != 0)
{
flag = -1;
break;
}
}
}
if (flag==0)
{
prnitf ("It is a IDENTITY MATRIX\n");
}
else
{
printf ("It is NOT an identity matrix\n");
}
return 0;
}
Input:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Output:
1 2 3
6 5 4
7 8 9
#include <stdio.h>
int main() {
int rows, cols;
// Input the number of rows and columns
printf("Enter the number of rows: ");
scanf("%d", &rows);
printf("Enter the number of columns: ");
scanf("%d", &cols);
3. Transpose of a Matrix
Input:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Output:
[[1, 4, 7],
[2, 5, 8],
[3, 6, 9]]
int main() {
int n;
int matrix[10][10];
return 0;
}
Input: Computer
Output: retupmoC
#include <stdio.h>
int main() {
char inputString[100];
reverseString(inputString);
return 0;
}
// Move pointers
start++;
end++;
}
}
#include <stdio.h>
int main() {
char inputString[100];
// Input a string
printf("Enter a string: ");
fgets(inputString, sizeof(inputstring), stdin);
// Call the function to count vowels
int vowelCount = countVowels(inputString);
return true;
}
return vowelCount + 1;
}
Input:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Output: 45
#include <stdio.h>
int main() {
int rows, cols;
int matrix[[rows][cols]];
return 0;
}