Purpose of this blog is to make programming easy , weak programmers may get help from my blog i tried my best to post some of my codes in form of easiest approach, I think this blog is perfect c++ guide in form of online blog. please consult my all codes and suggest all of it with your class mates. Share experiences & knowledge with your juniors. Make yourself habitual to write different programs for 2 hours a day daily.
Monday, 25 March 2013
C++ adding first five location of two arrays
#include<iostream.h>
#include<conio.h>
void main(){ clrscr();
int a[5],b[5]; cout<<"Enter first 5 numbers = ";
for(int i=0;i<5;i++){
cin>>a[i]; } cout<<"Enter Second 5 numbers = ";
for(int j=0;j<5;j++){
cin>>b[j]; } int s[5];
for(int x=0;x<5;x++){
s[x]=a[x]+b[x];
cout<<a[x]<<" + "<<b[x]<<" = "<<s[x]<<endl;
} getch();
}
Sunday, 24 March 2013
c++ Enter the Integer between 1 to 7 and get the required day
#include<iostream.h>
#include<conio.h>
void main()
{
int integer;
gotoxy(15,5);
cout<<"enter any integer between 1 to 7 to finday the day:"; cin>>integer;
switch(integer){
case 1: cout<<"Monday"; break;
case 2: cout<<"Tuesday"; break;
case 3: cout<<"Wednesday"; break;
case 4: cout<<"Thursday"; break;
case 5: cout<<"Friday"; break;
case 6: cout<<"Saturday"; break;
case 7: cout<<"Sunday"; break;
defaut:
cout<<"Wrong options"; } getch();
}
C++ How to find the power of any number Easy Approach by two methods
#include<iostream.h>
int main()
{
int b,e;
cout<<"enter a base value:";
cin>>b;
cout<<"enter a exponent Value:";
cin>>e;
long int r=b;
while (e>1)
{
e=e-1;
r=b*r;
}
cout<<r;
return 0;
}
Another program with different method in visual studio
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int b;
int p;
int temp;
cout<<"Enter the value of base = "; cin>>b;
cout<<"Enter the value of power = "; cin>>p;
temp = b;
while(p>1)
{
b = b* temp;
p--;
}
cout<<"the power of the value is as under = "<<b;
_getch();
}
Saturday, 23 March 2013
C++ GPA & CGPA Calculator Program
You can see this program in C# also at on another blog
http://csharpisbest.blogspot.com/2013/06/c-cgpa-caclulator-form-application.html
Program of gpa calculator is also done in functions go to this link to view that code
- #include<iostream.h>
- #include<conio.h>
- //www.programmingisbest.blogspot.com
- void main()
- {
- float x[5]; float cpa;
- char name[15],fname[15]; int i=1; int cr[5]; float result[5];
- cout<<"please enter your name: ";
- cin>>name;
- cout<<"please enter your father name:";
- cin>>fname;
- cout<<"please enter your previous cgpa = ";
- cin>>cpa;
- while(i<6)
- {//www.programmingisbest.blogspot.com
- cout<<"enter the marks of the subject"<<i<<" = ";
- cin>>x[i];
- cout<<"enter the credit hour of that subject = ";
- cin>>cr[i];
- result[i]=cr[i]*x[i];
- i++;
- }
- int gm;float sum; float gpa;
- gm=cr[1]+cr[2]+cr[3]+cr[4]+cr[5];
- sum = result[1]+result[2]+result[3]+result[4]+result[5];
- gpa=sum/gm;
- cout<<"\n\n\n\n";
- cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"; cout<<"xxxR.E.S.U.L.Txxx\n"; cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
- cout<<"Your gpa is as under = "<<gpa<<endl; float kk; kk=(gpa*cpa)/2; cout<<"your cgpa is as under = "<<kk<<endl;
- if(kk>2 && kk<4)
- {
- cout<<"You are Qualified";
- }
- else if(kk<2 && kk>1.5)
- {
- cout<<"You are Probiation";
- }
- else if(kk<1.5)
- {
- cout<<"You are at chance";
- }
- else {
- cout<<"try again";
- }
- getch();
- }
Using Functions make Calculator by return their results C++
#include<iostream.h>
int add(int x,int y){return x+y;}
int sub(int x,int y){return x-y;}
int mult(int x,int y){return x*y;}
int div(int x,int y){return x/y;}
int main()
{
int a,b;
cout<<"enter any two numbers:";
cin>>a>>b;
cout<<"sum = "<<add(a,b);
cout<<"\nsub = "<<sub(a,b);
cout<<"\nmultiply = "<<mult(a,b);
cout<<"\ndivide = "<<div(a,b);
}
Subscribe to:
Posts (Atom)