Wednesday, 28 August 2019
Saturday, 29 June 2019
Program to illustrate modulo operator in c
// Program to illustrate modulo divisor
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,r;
clrscr();
printf("\nEnter dividend m and divisor n value:");
scanf("%d%d",&m,&n);
r=m-(m/n)*n;
printf("\n\n\n Result:%d",r);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,r;
clrscr();
printf("\nEnter dividend m and divisor n value:");
scanf("%d%d",&m,&n);
r=m-(m/n)*n;
printf("\n\n\n Result:%d",r);
getch();
}
Tuesday, 5 March 2019
Program to illustrate pointer arithmetic
Program to illustrate pointer arithmetic without increment operator
#include <stdio.h>
void main()
{
int a[5]={10,20,30,40,50};
int *p;
int *q;
p=&a[1];
q=&a[4];
printf("\n value is %d",(*p + *q));
}
output:
Program to illustrate pointer arithmetic with increment operator
#include <stdio.h>
void main()
{
int a[5]={10,20,30,40,50};
int *p;
int *q;
p=&a[1];
q=&a[4];
p++;
printf("\n value is %d",(*p + *q));
q++;
printf("\n value is %d",(*p + *q));
}
output:
#include <stdio.h>
void main()
{
int a[5]={10,20,30,40,50};
int *p;
int *q;
p=&a[1];
q=&a[4];
printf("\n value is %d",(*p + *q));
}
output:
Program to illustrate pointer arithmetic with increment operator
#include <stdio.h>
void main()
{
int a[5]={10,20,30,40,50};
int *p;
int *q;
p=&a[1];
q=&a[4];
p++;
printf("\n value is %d",(*p + *q));
q++;
printf("\n value is %d",(*p + *q));
}
output:
Program on single and double pointer
Program on single and double pointer
#include <stdio.h>
void main()
{
int x=4,y,z;
int *sp;
int **dp;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
sp=&x;
printf("\n y value is %p",sp);
printf("\n y address is %p",&sp);
dp=&sp;
printf("\n z value is %p",dp);
printf("\n z address is %p",&dp);
*sp+=1;
y=*sp;
printf("\n y value is %d",y);
**dp+=3;
z=**dp;
printf("\n z value is %d",z);
printf("\n value of x+y+z =%d",(x+y+z));
}
output:
#include <stdio.h>
void main()
{
int x=4,y,z;
int *sp;
int **dp;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
sp=&x;
printf("\n y value is %p",sp);
printf("\n y address is %p",&sp);
dp=&sp;
printf("\n z value is %p",dp);
printf("\n z address is %p",&dp);
*sp+=1;
y=*sp;
printf("\n y value is %d",y);
**dp+=3;
z=**dp;
printf("\n z value is %d",z);
printf("\n value of x+y+z =%d",(x+y+z));
}
output:
Program to illustrate single pointer and double pointer
Program to illustrate pointer variable using single pointer
#include <stdio.h>
int main()
{
int x=50,*y;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
y=&x;
printf("\n y value is %p",y);
printf("\n y address is %p",&y);
printf("\n y value is %d",*y);
return 0;
}
output:
Program to illustrate pointer variable using double pointer
#include <stdio.h>
void main()
{
int x=10,*y;
int **z;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
y=&x;
printf("\n y value is %p",y);
printf("\n y address is %p",&y);
z=&y;
printf("\n z value is %p",z);
printf("\n z address is %p",&z);
printf("\n y value is %d",*y);
printf("\n z value is %d",**z);
}
output:
#include <stdio.h>
int main()
{
int x=50,*y;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
y=&x;
printf("\n y value is %p",y);
printf("\n y address is %p",&y);
printf("\n y value is %d",*y);
return 0;
}
output:
#include <stdio.h>
void main()
{
int x=10,*y;
int **z;
printf("\n x value is %d",x);
printf("\n x address is %p",&x);
y=&x;
printf("\n y value is %p",y);
printf("\n y address is %p",&y);
z=&y;
printf("\n z value is %p",z);
printf("\n z address is %p",&z);
printf("\n y value is %d",*y);
printf("\n z value is %d",**z);
}
output:
Program to illustrate transpose of a matrix
Program to illustrate transpose of a matrix
#include <stdio.h>
void main()
{
int row, col, i, j, first[10][10], trans[10][10];
printf("Enter the number of rows and columns of first matrix\n");
scanf("%d%d", &row, &col);
printf("Enter the %d elements of first matrix\n",row * col);
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf("%d", &first[i][j]);
}
}
printf("\nFirst matrix :\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d\t", first[i][j]);
}
printf("\n");
}
for (i = 0; i < row; i++)
{
for (j = 0 ; j < col; j++)
{
trans[i][j] = first[j][i];
}
printf("\n");
}
printf("\n Transpose of first matrix\n ");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d\t", trans[i][j]);
}
printf("\n");
}
}
#include <stdio.h>
void main()
{
int row, col, i, j, first[10][10], trans[10][10];
printf("Enter the number of rows and columns of first matrix\n");
scanf("%d%d", &row, &col);
printf("Enter the %d elements of first matrix\n",row * col);
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf("%d", &first[i][j]);
}
}
printf("\nFirst matrix :\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d\t", first[i][j]);
}
printf("\n");
}
for (i = 0; i < row; i++)
{
for (j = 0 ; j < col; j++)
{
trans[i][j] = first[j][i];
}
printf("\n");
}
printf("\n Transpose of first matrix\n ");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d\t", trans[i][j]);
}
printf("\n");
}
}
Monday, 4 March 2019
Program to illustrate n number of students records using structure
Program to illustrate n number of students records using structure
#include <stdio.h>
struct student
{
// defining a structure
char name[33];
int sno,sub1,sub2;
float tot;
} s[11];
int main()
{
int i,n;
printf("\n Enter the number of students information :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n Enter student number :");
scanf("%d",&s[i].sno);
printf("\n Enter student name :");
scanf("%s",s[i].name);
printf("\n Enter student mark in subject1 :");
scanf("%d",&s[i].sub1);
printf("\n Enter student mark in subject2 :");
scanf("%d",&s[i].sub2);
}
printf("\n **** Student Details **** :");
printf("\n SNO --- SNAME --- SUB1 --- SUB2 --- TOTAL");
for(i=1;i<=n;i++)
{
s[i].tot = s[i].sub1 + s[i].sub2;
printf("\n %d --- %s --- %d --- %d --- %f ",s[i].sno,s[i].name,s[i].sub1,s[i].sub2,s[i].tot);
}
return 0;
}
output:
#include <stdio.h>
struct student
{
// defining a structure
char name[33];
int sno,sub1,sub2;
float tot;
} s[11];
int main()
{
int i,n;
printf("\n Enter the number of students information :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n Enter student number :");
scanf("%d",&s[i].sno);
printf("\n Enter student name :");
scanf("%s",s[i].name);
printf("\n Enter student mark in subject1 :");
scanf("%d",&s[i].sub1);
printf("\n Enter student mark in subject2 :");
scanf("%d",&s[i].sub2);
}
printf("\n **** Student Details **** :");
printf("\n SNO --- SNAME --- SUB1 --- SUB2 --- TOTAL");
for(i=1;i<=n;i++)
{
s[i].tot = s[i].sub1 + s[i].sub2;
printf("\n %d --- %s --- %d --- %d --- %f ",s[i].sno,s[i].name,s[i].sub1,s[i].sub2,s[i].tot);
}
return 0;
}
output:
Subscribe to:
Posts (Atom)
Programs in turboc3 : Files
File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...
-
C TOKENS: The Smallest individual units are known as ‘C’ Tokens. ‘C’ as six types of tokens: 1. KEY WORDS 2. IDENTIFIERS 3. CONSTANTS 4.VARI...
-
File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...
-
Functions in c A function is a set of statements that takes input, do some specific computation and produces output. Function Declarat...





