C Program for Addition of two numbers. C program for Addition of two integers.
void main()
{
int i, j,k;
printf("Enter the two numbers to be added--");
scanf("%d%d",&i,&j);
k=i+j;
printf("\nAddition of %d and %d is =%d",i,j,k);
}
The above program accepts two numerals as input and then gives the output.
C Language , C Programs, Data Structures, Simplified C programs, easy C programs
Search This Blog
Saturday, September 14, 2013
Friday, May 24, 2013
Steps to begin C and Datastructures Programming| Program on Stack
C and Datastructures programming. How to begin C and Datastructures programming. Steps to be followed.We will see example of Stack.
Firstly Identify the problem.
Secondly ,find out the operations to be performed.
STACK: Ordered collection of homogeneous items is Stack.
1) FILO (First in last out)
2)Grows dynamically at one end while another end is fixed.
Program on Stack
# define Max 100;
struct stack{
int top;
int item[Max] ;
};
main()
{
struct stack s;
}
void push(struct stack *ps,int x)
{
if (ps->top==Max-1)
{
printf("Stack is full");
exit();
}
ps->item[++ps->top]=x;
}
topofstack(struct stack *ps)
return(ps->item[ps->top]);
int empty(struct stack *ps)
{
return(ps->top==-1);
}
int pop(struct stack *ps)
{
int x;
if empty()
{
printf("Stack is empty");
exit();
}
return(ps->item[++ps->top]);
}
Firstly Identify the problem.
Secondly ,find out the operations to be performed.
STACK: Ordered collection of homogeneous items is Stack.
1) FILO (First in last out)
2)Grows dynamically at one end while another end is fixed.
Program on Stack
# define Max 100;
struct stack{
int top;
int item[Max] ;
};
main()
{
struct stack s;
}
void push(struct stack *ps,int x)
{
if (ps->top==Max-1)
{
printf("Stack is full");
exit();
}
ps->item[++ps->top]=x;
}
topofstack(struct stack *ps)
return(ps->item[ps->top]);
int empty(struct stack *ps)
{
return(ps->top==-1);
}
int pop(struct stack *ps)
{
int x;
if empty()
{
printf("Stack is empty");
exit();
}
return(ps->item[++ps->top]);
}
Subscribe to:
Comments (Atom)