BCA Raipur - BCA Notes S-1

Post your notes and other just by mailing us at bcaraipur@live.com

BCA Raipur - BCA Notes S-2

Post your notes and other just by mailing us at bcaraipur@live.com

BCA Raipur - BCA Notes S-3

Post your notes and other just by mailing us at bcaraipur@live.com

BCA Raipur - BCA Notes S-4

Post your notes and other just by mailing us at bcaraipur@live.com

BCA Raipur - BCA Notes S-5

Post your notes and other just by mailing us at bcaraipur@live.com

google search

Popular Posts


Welcome to BCA Notes

>>>>>>>>>>>>>>>>

Visitors

Search This Blog

Blogger templates

Visitor Map


Thursday, 27 March 2014

Static keyword

The static keyword can be used to declare variables, functions, class data members and class functions.

 

By default, an object or variable that is defined outside all blocks has static duration and external linkage. Static duration means that the object or variable is allocated when the program starts and is deallocated when the program ends. External linkage means that the name of the variable is visible from outside the file in which the variable is declared. Conversely, internal linkage means that the name is not visible outside the file in which the variable is declared.

 

The static keyword can be used in the following situations.

·         When you declare a variable or function at file scope (global and/or namespace scope), the static keyword specifies that the variable or function has internal linkage. When you declare a variable, the variable has static duration and the compiler initializes it to 0 unless you specify another value.

·         When you declare a variable in a function, the static keyword specifies that the variable retains its state between calls to that function.

·         When you declare a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. A static data member must be defined at file scope. An integral data member that you declare as const static can have an initializer.

·         When you declare a member function in a class declaration, the static keyword specifies that the function is shared by all instances of the class. A static member function cannot access an instance member because the function does not have an implicit this pointer. To access an instance member, declare the function with a parameter that is an instance pointer or reference.

·         You cannot declare the members of a union as static. However, a globally declared anonymous union must be explicitly declared static.

 



--
Regards


Arihant

- input output stream header file

 

 


<iostream.h>- input output stream header file 

Provides functionality to use an abstraction called streams specially designed to perform input and output operations on sequences of character, like files or strings. 
Objects cin, cout are from iostream header. 
<conio.h> console input output header file 
conio.h is a C header file used in old MS-DOS compilers to create text user interfaces 

Both are header files which contains libery of serveral functions (use for input & output ). 
eg. clearscr() ,getch() are from conio.h 
This is type of opening files before we use these function. 
If we use these function them without importing header files , sometimes compiler throws error

 

 

Including this header may automatically include other headers, such as <ios>, <streambuf>, <istream>, <ostream>and/or <iosfwd>.


Note that the 
iostream class is mainly declared in header <istream>.


Objects

 

Narrow characters (char)

Standard input stream (object )

cout

Standard output stream (object )

cerr

Standard output stream for errors (object )

clog

Standard output stream for logging (object )

 

Wide characters (wchar_t)

wcin

Standard input stream (wide) (object )

wcout

Standard output stream (wide) (object )

wcerr

Standard output stream for errors (wide-oriented) (object )

wclog

Standard output stream for logging (wide) (object )

 



--
Regards


Arihant

Wednesday, 26 March 2014

Structure with array

#include<iostream.h>
struct stud
{
char name[20],mo[10],cou[10],age[3];

}d[10];
main()
{
int a;
for(a=1;a<=3;a++)
{
cout<<"Enter your name:-";
cin.getline(d[a].name,20);
cout<<"Enter age:-";
cin.getline(d[a].age,3);
cout<<"Enter your mobile no:-";
cin.getline(d[a].mo,10);
cout<<"Enter your course:-";
cin.getline(d[a].cou,10);

}
cout<<"-----------------------------"<<endl;
cout<<"-----------------------------"<<endl;
for(a=1;a<=3;a++)
{
cout<<"Info of No."<<a<<"Student"<<endl;
cout<<"Name:"<<d[a].name<<endl;
cout<<"Age:"<<d[a].age<<endl;
cout<<"Mobile No.:"<<d[a].mo<<endl;
cout<<"Course:"<<d[a].cou<<endl;
}
}

Thursday, 20 March 2014

Passing Pointer to an Array

#include<iostream.h>
main()
{
int a[5];
int *pt;
pt=a;
*pt=a[0]=10;
pt++;
*pt=a[1]=20;
pt++;
*pt=a[2]=30;
pt++;
*pt=a[3]=40;
pt++;
*pt=a[4]=50;
pt++;
for ( int i=0;i!=5;i++)
{
cout<<a[i]<<"\n";
}


}

Passing Pointer to an Array

#include<iostream.h>
main()
{
int a[5];
int *pt;
pt=a;
for(int p=0;p<5;p++)
{
cout <<"Enter Value to be insterted in "<<p<<" Index:";
cin>>*pt;
a[p]=*pt;

}
cout<<"Value at O Index:"<<a[0]<<"\n";
cout<<"Value at 1 Index:"<<a[1]<<"\n";
cout<<"Value at 2 Index:"<<a[2]<<"\n";
cout<<"Value at 3 Index:"<<a[3]<<"\n";
cout<<"Value at 4 Index:"<<a[4]<<"\n";
//cout<<"Value at O Index:"<<a[5]<<"\n";
}

Swapping two number Using Pointer C++

#include<iostream.h>
main()
{
int a,b,c;
int *i,*j;
cout<<"Enter integer:";
cin>>a;
i=&a;
cout<<"Enter integer:";
cin>>b;
j=&b;
c=*i;
a=*j;
b=c;
cout<<a<<b;

}

Monday, 17 March 2014

Factorial of any Number using Class & Object.

#include<iostream.h>
class factorial
{
 public:
 int count,n,fact;
 public:
 void fun()
 {
  cout<<"Enter The No. :\n";
  cin>>n;
  count=1;
  fact=1;
  while(count!=n)
  {
   count++;
   fact = fact * count;
  }
  cout<<"Factorial Value is :\n"<<fact<<endl;
  
 }
};
main()
{
 class factorial f1;
 f1.fun();
 
 
}