Q1: Write a C program to print a "Matrix" as an output by using arrays?
#include<conio.h>
#include<stdio.h>
void main()
{
int a[2][3],i,j;
clrscr();
printf("Enter elements in Matrix\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("Enter elements at a[%d][%d]\t\n",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\nOUTPUT\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("%d",a[i][j]);
}
printf("\n");
}
getch();
}
***********************************************************************************
Sample Output:
#include<conio.h>
#include<stdio.h>
void main()
{
int a[2][3],i,j;
clrscr();
printf("Enter elements in Matrix\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("Enter elements at a[%d][%d]\t\n",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\nOUTPUT\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("%d",a[i][j]);
}
printf("\n");
}
getch();
}
***********************************************************************************
Sample Output:
Comments
Post a Comment
Thanks for the comment and don't forget to subscribe.