Number of Variables

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

#include<stdio.

h>
#include<conio.h>
#include<iostream.h>
#include<fstream.h>
class student
{
private:
char ch;
int counter,counterf,counterc;
public:
student()
{
counter=0;
counterf=0;
counterc=0;
}
void copy_int()
{
fstream obj1;
obj1.open("number.cpp",ios::in);
obj1.get(ch);
while(!obj1.eof())
{
if(ch=='"')
{
obj1.get(ch);
while(ch!='"')
{
obj1.get(ch);
}
}
if(ch=='i')
{
obj1.get(ch);
if(ch=='n')
{
obj1.get(ch);
if(ch=='t')
{
obj1.get(ch);
if(ch==' ')
{
obj1.get(ch);
while(ch!=';')
{
obj1.get(ch);
if(ch==',')
counter++;
else
continue;
}
counter++;
}
}
}
}
obj1.get(ch);
}
cout<<"THE NUMBER OF INTEGER VARIABLES"<<counter;
}

void copy_float()
{
fstream obj1;
obj1.open("number.cpp",ios::in);
obj1.get(ch);
while(!obj1.eof())
{
if(ch=='"')
{ obj1.get(ch);
while(ch!='"')
{
obj1.get(ch);
}
}
if(ch=='f')
{
obj1.get(ch);
if(ch=='l')
{
obj1.get(ch);
if(ch=='o')
{
obj1.get(ch);
if(ch=='a')
{
obj1.get(ch);
if(ch=='t')
{
obj1.get(ch);
if(ch==' ')
{
obj1.get(ch);
while(ch!=';')
{

obj1.get(ch);
if(ch==',')
counterf++;
else
continue;
}
counterf++;
}
}
}
}
}
}
obj1.get(ch);
}
cout<<"THE NUMBER OF FLOAT VARIABLES"<<counterf;
}

void copy_char()
{
fstream obj1;
obj1.open("number.cpp",ios::in);
obj1.get(ch);
while(!obj1.eof())
{
if(ch=='"')
{
obj1.get(ch);
while(ch!='"')
{
obj1.get(ch);
}
}
if(ch=='c')
{
obj1.get(ch);
if(ch=='h')
{
obj1.get(ch);
if(ch=='a')
{
obj1.get(ch);
if(ch='r')
{
obj1.get(ch);
if(ch==' ')
{
obj1.get(ch);
while(ch!=';')
{
obj1.get(ch);
if(ch==',')
counterc++;
else
continue;
}
counterc++;
}
}
}
}
}
obj1.get(ch);
}
cout<<"number of char variables"<<counterc;
}

};
void main()
{
student object;
object.copy_int();
object.copy_float();
object.copy_char();
}

You might also like