12 March 2022

Today's C File Program

File Program

#include<stdio.h>

#include<conio.h>

void main()

{

FILE *fp1, *fp2, *fp3;


fp1 = fopen("1.txt", "w");

fp2 = fopen("2.ppp", "w");

fp3 = fopen("3.xyz", "w");


fprintf(fp1, "Welcome to BCA");

fprintf(fp2, "Gujarat");

fprintf(fp3, "University");


fcloseall();

}


Header File Program

#include<stdio.h>

#include<conio.h>

#include"reverse.c"


void main()

{

long int no;

clrscr();


printf("\nEnter number: ");

scanf("%ld", &no);


printf("\n\nReverse number = %ld", reverse(no)) ;


getch();

}

Header File Name. reverse.c

long reverse(long int no)

{

long revno=0;

int rem;


while(no > 0)

{

rem = no % 10;

revno = revno * 10 + rem;

no = no / 10;

}


return revno;

}

No comments:

Post a Comment