skip to main |
skip to sidebar
/
*
Name: WAP to store vowels from one file to another
Author: Parveen Malik
Date: 20/09/11 08:45
*/
#include <stdio.h>
#include <conio.h>
void main()
{
char c;
FILE *f,*f1;
f=fopen("STRING","w");
printf("Enter String :\n ");
while(scanf("%c",&c)!=EOF)
putw(c,f);
fclose(f);
f=fopen("STRING","r");
f1=fopen("VOWELS","w");
while((c=getw(f))!=EOF)
if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')||(c=='A')||(c=='E')||(c=='I')||(c=='O')||(c=='U'))
putw(c,f1);
fclose(f);
fclose(f1);
f1=fopen("VOWELS","r");
printf("\nVOWELS : \n");
while((c=getw(f1))!=EOF)
printf(" %c",c);
getch();
}
OUTPUT :
/*
Name: Write a C program to displays the position or index in the string S where the string T begins, or -1 if S doesn't contain T. */
/*
Author: Parveen Malik
Date: 18/09/11 08:58
*/
#include<stdio.h>
#include<conio.h>
int main(void)
{
char str[10],tr[10];
int i,j,pos;
int flag=0;
int count=0;
printf("Enter the main string : ");
gets(str);
printf("Enter the substring : ");
gets(tr);
for(i=0;str[i]!='\0';i++)
{
if(str[i]==str[0])
{
pos=i;
for(j=0;tr[j]!='\0';j++)
{
if(str[i]==tr[j])
count++;
i++;
}
flag=1;
break;
}
}
if(flag==1&&count==strlen(tr))
printf("\nPostion :%d, and T is a substring of S",pos+1);
else if(flag==1&&count<strlen(tr))
printf("\nPosition : %d, and T is not a substring of S",pos+1);
else
printf("\nIndex : -1");
getch();
}
OUTPUT: