Posts

Showing posts from December, 2021

Small Unwonderful Story

Image
  links:                                          Hobbies:                                             Sketches The Girl...                                         Small Unwonderful Story  Programming Languages:                                   C++                                JAVA                                HTML       Something:         ...

Java

file handling in c

  file handling using c programming:-  example 1 :- write to a text file-    #include<stdio.h>   #include<conio.h>   #include<stdlib.h>      int main() {   FILE *fp;   int num;           fp=fopen("files1.1.txt","w");   if(fp==NULL) { printf(" file does not exit"); exit(1); } printf("enter the num:"); scanf("%d",&num); fprintf(fp,"%d",num); printf("\n value of n is :%d",num); fclose(fp); return 0; }      example 2:- read to a text file-      #include<stdio.h>    #include<conio.h>    #include<stdlib.h> int main() { FILE *fp; int num;       //if((fp=fopen("files1.1.txt","r"))=NULL)         fp=fopen("files1.1.txt","r"); if(fp==NULL) { printf(" file does not exit"); exit(1); } fscanf(fp,"%d",&num); printf("\n value of n=%d",num); fclo...

Images

Image
 

DATA STRUCTURE AND ALGORITHM

  Data Structure and Algorithm:     A   data structure   is a particular way of organizing data in a computer so that it can be used effectively. For example, we can store a list of items having the same data-type using the  array  data structure.     In the data structure there two type of searching :   1. sequential search (linear search)   2. binary search   program of sequntial search:   #include<stdio.h> #include<conio.h> int linear_search(int a[],int n,int key) { for(int i=0; i<n; i++) if(a[i]==key) return i; return -1; } int main() { int a[10],n,key,ans; printf("enter how many numbers:"); scanf("%d",&n); for(int i=0; i<n; i++) { printf("enter the number:"); scanf("%d",&a[i]); } printf("\n enter the key:"); scanf("%d",&key); ans=linear_search(a,n,key); if(ans==-1) printf("\n sorry yar ur element not found!!!"); else printf("\n eleme...