Popular posts from this blog
Factorial Program using classes C++
Classes are basically created to compress a big program into a small program that is meaningful too. Here , we gonna work on a factorial program using classes. #include<iostream.h> #include<conio.h> class factorial { int i,f,num; public: void read(); void fact(); void display(); }; void factorial::read() { cout<<"Enter an Integer to get Factorial:- "; cin>>num; } void factorial::fact() { f=1; for(i=1;i<=num;i++) { f=f*i; } } void factorial::display() { cout<<"Factorial of "<<num<<" :-"<<f; } void main() { factorial vk; clrscr(); vk.read(); vk.fact(); vk.display(); getch(); }
File input/output program to access no. of character, spaces, tabs...
By using File Input/Output , we gonna count:- No. of characters No. of blanks No. of tabs No. of lines So, here the code for the above. /*Pre Processors */ #include<stdio.h> #include<conio.h> int main() /*Main function*/ { FILE *fp; char ch; clrscr(); int nol=0, not=0, nob, noc=0; fp=fopen("EMPLOYEE.TXT","r"); while(1) { ch=fgetc(fp); if(ch==EOF) break; noc++; if(ch==' ') nob++; if(ch=='\n') nol++; if(ch=='\t') not++;...

Comments
Post a Comment