Posts
4. Write a program to read a text file “brijesh.txt “ count and display the number of alphanets present in it.
- Get link
- X
- Other Apps
#include <stdio.h> #include <stdlib.h> #include <string.h> #include<conio.h> int main(void) { char str[80]; int l=0; clrscr(); FILE *fp; if((fp = fopen("brijesh.txt", "w"))==NULL) { printf("Cannot open file.\n"); exit(1); } do { printf("Enter a string :\n"); gets(str); l=strlen(str); printf("charecter lenth are\t%d\n",l); strcat(str, "\n"); /* add a newline */ fputs(str, fp); } while(*str!='\n'); return 0; }
6. Write a program to create a text file which contain some text.
- Get link
- X
- Other Apps
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char str[80]; FILE *fp; if((fp = fopen("brijesh.txt", "w"))==NULL) { printf("Cannot open file.\n"); exit(1); } do { printf("Enter a string (CR to quit):\n"); gets(str); strcat(str, "\n"); /* add a newline */ fputs(str, fp); } while(*str!='\n'); return 0; }
C program for conver kilometer into inch ,feet,centimeter and meter
- Get link
- X
- Other Apps
#include<stdio.h> #include<conio.h> void main() { float km,m,cm,ft,inch; clrscr(); printf("enter the distance in kilometres "); scanf("%f",&km); m=km*1000; cm=m*100; C inch=cm/2.54; ft=inch/12; printf(" distance in meters is %f",m); printf(" distance in centimetres is %f",cm); printf(" distance in feet is %f",ft); printf(" distance in inches is %f",inch); getch(); }