Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
h>
#include<conio.h>
int main()
FILE *fp,fn;
char ch;
int w,v,c,s;
gets(fn);
fp=fopen("test.txt","r");
if(fp==NULL)
getch();
exit(1);
else
printf("%c",ch)
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'|
|ch=='I'||ch=='O'||ch=='U'||)
v++;
s++;
else
c++;
w=s+1;
}
fclose(fp);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#define p printf
struct node
int data;
}*start=NULL,*temp,*new_node,*pre;
void insert()
{ //
int i,d,po,j;
scanf("%d",&i);
scanf("%d",&d);
new_node->data=d;
switch(i)
new_node->next=start;
start=new_node;
break;
new_node->next=NULL;
temp=start;
while(temp->next!=NULL)
temp=temp->next;
temp->next=new_node;
break;
case 3:
temp=start;
scanf("%d",&po);
j=1;
while(j<po-1)
temp=temp->next;
j++;
new_node->next=temp->next;
temp->next=new_node;
break;
default:
void del()
int i,po,j;
scanf("%d",&i);
switch(i)
{
case 1:
temp=start;
start=temp->next;
free(temp);
break;
case 2:
temp=start;
pre=start;
while(temp->next!=NULL)
pre=temp;
temp=temp->next;
pre->next=NULL;
free(temp);
break;
case 3:
temp=start;
pre=start;
p("\nenter the position ");
scanf("%d",&po);
j=1;
while(j<po)
pre=temp;
temp=temp->next;
j++;
pre->next=temp->next;
free(temp);
break;
default:
void show()
temp=start;
while(temp!=NULL)
p("%d->",temp->data);
temp=temp->next;
void create()
char a;
int d=0;
do
scanf("%d",&d);
new_node->data=d;
if(start==NULL)
start=new_node;
new_node->next=NULL;
}
else
temp=start;
while(temp->next!=NULL)
temp=temp->next;
new_node->next=NULL;
temp->next=new_node;
fflush(stdin);
scanf("%c",&a);
}while(a=='y'||a=='Y');
int main()
int n;
while(1)
p("\n1)create\n2)show\n3)insert\n4)delete\n5)exit\nEnter
your choice : ");
scanf("%d",&n);
switch(n)
case 1:
create();
break;
case 2:
show();
break;
case 3:
insert();
break;
case 4:
del();
break;
case 5:
return 0;
default:
p("invalid input.");
getch();
}
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
struct link
int coe;
int p;
};
char ch;
do
scanf("%d",&node->coe);
printf("enter power:");
scanf("%d",&node->p);
node->next=(struct link*)malloc(sizeof(struct link));
node=node->next;
node->next=NULL;
printf("\n continue(y/n):");
ch=getch();
while(ch=='y' || ch=='Y');
while(node->next!=NULL)
printf("%dx^%d",node->coe,node->p);
node=node->next;
if(node->next!=NULL)
printf("+");
}
void polyadd(struct link *poly1,struct link *poly2,struct link *poly)
if(poly1->p>poly2->p)
poly->p=poly1->p;
poly->coe=poly1->coe;
poly1=poly1->next;
else if(poly1->p<poly2->p)
poly->p=poly2->p;
poly->coe=poly2->coe;
poly2=poly2->next;
else
poly->p=poly1->p;
poly->coe=poly1->coe+poly2->coe;
poly1=poly1->next;
poly2=poly2->next;
poly=poly->next;
poly->next=NULL;
while(poly1->next || poly2->next)
if(poly1->next)
poly->p=poly1->p;
poly->coe=poly1->coe;
poly1=poly1->next;
if(poly2->next)
poly->p=poly2->p;
poly->coe=poly2->coe;
poly2=poly2->next;
}
poly=poly->next;
poly->next=NULL;
void main()
clrscr();
create(poly1);
create(poly2);
printf("\n1st Number:");
show(poly1);
printf("\n2nd Number:");
show(poly2);
polyadd(poly1,poly2,poly);
printf("\nAdded polynomial:");
show(poly);
getch();
}
#include<stdio.h>
#include<conio.h>
#define max 5
int front=-1,rear=-1;
int queue[max];
void insert()
int item;
int ch;
if(rear==max-1)
else
do
if(front==-1)
{
front++;
rear++;
scanf("%d",&item);
queue[rear]=item;
else
rear=rear+1;
scanf("%d",&item);
queue[rear]=item;
scanf("%d",&ch);
} while(ch==1);
void delet()
{
int item;
if(front<0)
getch();
else
item=queue[front];
front=front+1;
void display()
int i;
if(front==-1)
getch();
}
else
for(i=front;i<=max-1;i++)
int main()
int choice;
while(1)
scanf("%d",&choice);
switch(choice)
case 1:
insert();
break;
case 2:
delet();
break;
case 3:
display();
break;
case 4:
return 0;
}
#include<stdio.h>
#include<conio.h>
#define MAX 10
struct queue
int info[MAX];
int front,rear;
};
void insert(Q*,int);
void display(Q*p);
void del(Q*);
int main()
Q q;
int i,x,item;
q.front=q.rear=-1;
do
{
scanf("%d",&i);
switch(i)
scanf("%d",&x);
insert(&q,x);
break;
case 2:del(&q);
break;
case 3:display(&q);
break;
return 0;
default:
break;
}
}while(i!=4);
if(p->rear==MAX-1)
printf("\nqueue is overflow");
return;
p->info[++p->rear]=item;
void del(Q*p)
if(p->front==p->rear)
printf("\nqueue underflow");
return;
}
void display(Q*p)
if(p->front==p->rear)
return;
while(p->rear!=p->front)
}
#include<stdio.h>
#include<conio.h>
int main()
char ans;
int no[4],cho;
int i=0,j=-1,k=3,num;
int x;
do
printf("\n\tSTACK
REPRESENTATION\n\t1.PUSH\n\t2.POP\n\t3.SHOW\n\t4.EXIT");
fflush(stdin);
scanf("%d",&cho);
switch(cho)
{
case 1:
if(j==k)
else
printf("Enter a number");
scanf("%d",&num);
no[++j]=num;
}
break;
case 2:
if(j>-1)
no[j--]=0;
else
{
printf("\n\tStack Is Empty");
break;
case 3:
for(x=0;x<=j;x++)
printf(" %d",no[x]);
if(j<0)
break;
case 4:
getch();
default:
printf("Invalid Choice");
fflush(stdin);
ans=getche();
while(ans=='y'||ans=='Y');
getch();
}
#include<stdio.h>
#include<conio.h>
struct stack
int no;
*start=NULL;
void push();
int pop();
void display();
int main()
char ch;
int choice,item;
do
{
printf("\n 1: push");
printf("\n 2: pop");
printf("\n 3: display");
scanf("%d",&choice);
switch (choice)
case 1: push();
break;
case 2: item=pop();
break;
case 3: display();
break;
};
fflush(stdin);
scanf("%c",&ch);
while (ch=='Y'||ch=='y');
getch();
void push()
st *node;
node=(st *)malloc(sizeof(st));
scanf("%d",&node->no);
node->next=start;
start=node;
int pop()
st *temp;
temp=start;
if(start==NULL)
{
printf("stack is already empty");
getch();
else
start=start->next;
free(temp);
return(temp->no);
void display()
st *temp;
temp=start;
while(temp->next!=NULL)
printf("\nno=%d",temp->no);
temp=temp->next;
}
printf("\nno=%d",temp->no);
}
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
void main()
char st[100],ch;
int i,v,c,s,sy;
clrscr();
gets(st);
v=c=s=sy=0;
for(i=0;st[i]!='\0'; i++)
ch=toupper(st[i]);
if(isalpha(ch))
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
v++;
else
c++;
s++;
else
sy++;
getch();
}
#include<stdio.h>
#include<conio.h>
char stack[20];
int top=-1;
void push(char x)
Stack[++top]=x;
char pop()
If(top==-1)
return-1;
else
return stack[top--];
Int priority(char x)
If(x==’(‘)
return0;
if(x==’+’||x==’-‘)
return1;
if(x==’*’||x==’/’)
return 2;
return(-1);
void main()
char exp[20];
char*e,x;
clrscr();
scanf(“%s”,exp);
e=exp;
while(*e !=’\0’)
if(isalnum(*e))
printf(“%c”,*e);
else if(*e==’(‘)
push(*e);
else if(*e==’(‘)
while((x=pop()) !=’(‘)
printf(“%c”,x);
else
while(priority(stack[top])>=priority(*e))
printf(“%c”,pop());
push(*e);
e++;
while(top !=-1)
printf(“%c”,pop());
getch();