Professional Documents
Culture Documents
Avg =Sum/2;
Cout <<”sum=”<<Sum”\n”;
Cout <<”Avg=”<<Avg”\n”;
Return 0;
Data types
Built in
Return (x*y);
Return (p/q);
}
Int main()
Float a =10;
Float b=20;
Cout<<mul(a,b)<<”/n”;
Cout<<div(a,b)<<”/n”;
Return 0;
--------------------------------------------------------------------------------------------------------------------------------------
For loop
Main()
Cout<<”ankit”<<endl;
Output
ankit
ankit
main
{
Cout<<”Ankit”<<endl;
Cout<<”Ankit”<<endl;
Main()
Int =mypwd;
Cin>>mypwd;
If (pwd!=mypwd)
Cin>>mypwd;
Else
Break;
}
}
Main()
Int i=1;
Do
Cout<<”ankit”<<endl;
i++;
While (i<0);
#include <iostream>
int main()
// int num;
// cin>>num;
// for(int i;i<=10;i++)
//{
// cout <<num *i<<endl;
//}
return 0;
--------------------------------------------------------for loop-----------------------------------------------
#include <iostream>
int main()
int a;
cin>>a;
cout<<a<<"*"<<i<<"="<<a*i<<endl;
return 0;
Output
Multiplication of table
-----------------------------------if condition----------------------------------------------------------------------------
#include <iostream>
int main()
cout <<"enter the weather = "; //Input from the user in the form of weather
if (a=="rainy")
// if(a=="green")
// {
// cout<<"Go"<<endl;
// }
else
return 0;
-----------------------------else if ladder-------------------------------------------------------------------
#include <iostream>
class Person
private:
int age;
string name;
string address;
public:
void input()
cin>> age;
cin>> address;
void show()
cout<<"Address is ="<<address<<endl;
};
main()
Person ankush,ankit,rohit;
ankush.input();
ankush.show();
------------------------------------------------------constructor---------------------------------------------------------------
#include <iostream>
class A
{
public:
int a,b;
A()
a=10;
b=20;
void show()
cout<<a<<endl;
cout<<b<<endl;
};
main()
A obj =A();
obj.show();