  
            CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran             
            CBSE CLASS XII 
            
                
             
			
			    
			DATA FILE HANDLING OUTSIDE DELHI : 2008  
			Q. 1. Observe  the program segment given below carefully, and answer the question that follows  : 
		    class candidate 
		    { long Cid ; // Candidate’s Id 
		    char CName[20] ; // Candidate’s Name 
		    float Marks ; // Candidate’s Marks 
		    public ; 
		    void Enter( ) ; 
		    void Display( ) ; 
		    void MarksChange( ) ; //Function to change marks 
		    long R_Cid( ) {return Cid ;} 
		    } ; 
		    void MarksUpdate (long Id) 
		    { fstream File ; 
		    File.open (“CANDIDATE.DAT”, ios :: binary|ios::in|ios  :: out) ; 
		    Candidate C ; 
		    int Record = 0, Found = 0 ; 
		    while (!Found&&File.read((char*)&C,  sizeof(C))) 
		    { if (Id = =C.R_Cid( )) 
		    { cout << “Enter new Marks” ; 
		    C.MarksChange( ) ; 
 File.seekp(File.tellp( )-sizeof(C)); //Statement 1 
  //File.seekp(Record*sizeof(C)); 
  File.write((char*)&C,sizeof(C)); //Statement 2 
  //File.write((char*)&C,sizeof(Candidate)); 
		    Found = 1 ; 
		    } 
		    Record++ ; 
		    } 
		    if (Found = = 1) 
		    cout << “ Record Updated” ; 
		    File.close( ) ; 
		    } 
		    Write the Statement to position the File Pointer at  the beginning of the Record for which the 
		    Candidate’s Id matches with the argument passed, and  Statement 2 to write the updated Record at that 
		    position. 
						  Q. 1. b Write a function in C++ to count the number of  uppercase alphabets present in a text file “ARTICLE.TXT”. 
			Solution: 
						  void UpperLetters( ) 
		    { clrscr( ); 
		    ifstream fin("ARTICLE.TXT",ios::in); 
		    char ch; 
		    int uppercount=0; 
		    while(fin) 
		    { fin.get(ch); 
		    if(isupper(ch)) 
		    uppercount++; 
		    } 
		    cout<<"\nTotal number of Uppercase  alphabets in the file = "<<uppercount; 
		    getch( ); 
		    } 
			    
			 
            Paper By Mr. Ravi Kiran 
			Email Id : [email protected] 		   |