Showing posts with label Search. Show all posts
Showing posts with label Search. Show all posts

Dictionary Word Search C Program

How to write a C Program to Find Dictionary Word Search ?


Solution For C Program to Find a Word in Dictionary :

C Depth First Search

How to write a C Program Depth First Search in C Programming Language ?


Solution For C Program :

C Program To Search A Number Inside The Array

How to write a C Program To Search A Number Inside The Array in C Programming Language ?


Solution For C Program :

/*C Program To Search A Number Inside The Array.*/

#include<stdio.h>
#include<conio.h>
void main()
    {
    int i,num,flag=0,arr[5];
    printf("Enter 5 numbers for array:=\n");
    for(i=0;i<5;i++)
        {
        scanf("%d",&arr[i]);
        }
    printf("Enter number u want to search:=");
    scanf("%d",&num);
    for(i=0;i<5;i++)
        {
        if(arr[i]==num)
        {
        printf("number %d do exist in present array",num);
        flag=1;
        break;
        }
        }
        if(flag==0)
        {
        printf("number does not exist in the present array");
        }
    getch();
    }


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program To Write Data In A File And Search Data From File

How to write a C Program To Write Data In A File And Search Data From File in C Programming Language ?


Solution For C Program :

/*C Program To Write Data In A File And Search Data From File.*/


#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int r,found;
struct stud
    {
    char name[30];
    int age;
    int roll_no;
    }st;
FILE *fp;
fp=fopen("test.dat","r+t");
        if(fp==NULL)
            {
            printf("\nCannot open file\n");
            exit(1);
            }

printf("enter role no:");
found=0;
scanf("%d",&r);

while((!feof(fp))&&(found))
    {
    fread(&st,sizeof(stud),1,fp);
    if(st.roll_no==r)
    {
    fseek(fp,-sizeof(stud),SEEK_CUR);
    printf("enter new name\n");
    scanf("%s",st.name);
    fwrite(fp,sizeof(stud),1,fp);
    found=1;
    }
    }
    if(!found)
    printf("record not present");
    fclose(fp);
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable