Sunday, November 17, 2019

Program for Structure

#include<stdio.h>
#include<conio.h>
structure student
{
char name[15];
int roll,m1,m2,m3,total;
float per;
}z;
void main()
{

 printf("Enter Name:");
 scanf("%s",&z.name);
 printf("\nEnter Roll Number:");
 scanf("%d",&z.roll);
 printf("\nEnter Marks of Mathematics:");
 scanf("%d",&z.m1);
 printf("\nEnter Marks of C Programming:");
 scanf("%d",&z.m2);
 printf("\nEnter Marks of Fundamental of Computer:");
 scanf("%d",&z.m3);
 z.total=z.m1+z.m2+z.m3;
 z.per=z.total/3;
 printf("***********************************************************");
 printf("\nMarksheet\n");
 printf("\nName:%s",z.name);
 printf("\nRoll Number:%d",z.roll);
 printf("\nMathematics:%d",z.m1);
 printf("\nC Programming:%d",z.m2);
 printf("\nFundamental of Computer:%d",z.m1);
 printf("\nTotal Marks Obtained:%d",z.total);
 printf("\nPercentage:%f",z.per);
 getch();
}

Output:
Enter Name:XYZ                                                                                                                         
                                                                                                                                       
Enter Roll Number:55                                                                                                                   
                                                                                                                                       
Enter Marks of Mathematics:78                                                                                                          
                                                                                                                                       
Enter Marks of C Programming:89                                                                                                        
                                                                                                                                       
Enter Marks of Fundamental of Computer:80                                                                                              
***********************************************************                                                                            
Marksheet                                                                                                                              
                                                                                                                                       
Name:XYZ                                                                                                                               
Roll Number:55                                                                                                                         
Mathematics:78                                                                                                                         
C Programming:89                                                                                                                       
Fundamental of Computer:78                                                                                                             
Total Marks Obtained:247                                                                                                               
Percentage:82.00000

Saturday, October 19, 2019

Matrix Multiplication Program

// Matrix Multiplication Program

#include<stdio.h>
void main()
{
int c[2][2],i,a[2][2],b[2][2],j,k;
printf("Enter 5 numbers");
for(i=1;i<=2;i++)
    {
        for(j=1;j<=2;j++)
        {
        scanf("%d",&a[i][j]);
    printf("Elements of array are a[%d][%d]=%d\n",i,j,a[i][j]);
        }
   }
for(i=1;i<=2;i++)
    {
        for(j=1;j<=2;j++)
        {
        scanf("%d",&b[i][j]);
    printf("Elements of array are b[%d][%d]=%d\n",i,j,b[i][j]);
        }
   }
for(i=1;i<=2;i++)
    {
        for(j=1;j<=2;j++)
        {
            c[i][j]=0;
            for(k=1;k<=2;k++)
            {
       c[i][j]=c[i][j]+a[i][k]*b[k][j];
  
            }
        }
   }
 printf("\n ************************************************");
        printf("\n The Final Output is: ");
for(i=1;i<=2;i++)
    {
        for(j=1;j<=2;j++)
        {
      
    printf("\nElements of array are c[%d][%d]=%d\n",i,j,c[i][j]);
        }
   }
}

Friday, September 20, 2019

Program for Tower of Hanoi



#include<stdio.h>
void hanoi(int,char,char,char);
void main()
{
int n;
char A='A',B='B',C='C';
printf("Enter the number of Disks\n");
scanf("%d",&n);
printf("The Sequence is:\n");
hanoi(n,'A','B','C');
}
void hanoi(int n,char beg,char aux,char end)
{
if(n==1)
{
printf("The movement is %c->%c\n",beg,end);

}
else
{
hanoi(n-1,beg,end,aux);
printf("The movement is %c->%c\n",beg,end);
hanoi(n-1,aux,beg,end);
}}