Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }
In this C program we will perform operations over Linear Queue(i.e: Data insert Operation, Data remove Operation and display Operation). The Choice(i.e: data insert,remove or display) will be made by the user and The Number will be taken from the user(i.e: For Data insert Operation).
input:
The Choice(i.e Data insert, remove or display) & The Number (integers) (i.e. for Data insert Operations) (15,10,128 etc.)output:
The Operations will be excecuted as choosen by the user.
CODE---->
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 10
int Q[MAXSIZE],front=-1,rear=-1;
void qinsert(int x)
{
if(rear==MAXSIZE-1)
printf("\n Queue is Full.");
else if(front==-1)
{
front=0;
rear=0;
Q[front]=x;
}
else
{
rear++;
Q[rear]=x;
}
}
void qdelete()
{
if(front==-1)
printf("\n Queue is Empty.");
else if(front==rear)
{
printf("\n %d is removed from Queue.",Q[front]);
front=-1;
rear=-1;
}
else
{
printf("\n %d is deleted from Queue.",Q[front]);
front++;
}
}
void display()
{
int i;
printf("\n The Queue elements are...\n");
if(front==-1)
printf("\n No elements in Queue.");
else
{
for(i=front;i<=rear;i++)
printf(" %d ",Q[i]);
}
}
int main()
{
int choice,x;
while(1)
{
printf("\n 1.Data insert\n 2.Data Delete\n 3.Data Display\n 4.Exit");
printf("\n Please, Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: printf("\n Please, Enter the element : ");
scanf("%d",&x);
qinsert(x);
break;
case 2: qdelete();
break;
case 3: display();
break;
case 4: exit(0);
default : printf("\n wrong Choice.");
}
}
}
Such a Nice Working. Keep it up.
ReplyDeleteSummitsoft Wonderful Fonts Collection Fully Cracked 2024