Tuesday 17 December 2013

C++ Calculate Total days in Year by Input only February days in current year or else year

#include<iostream.h>
#include<conio.h>

void main()
{
int months[11]={31,31,30,31,30,31,31,30,31,30,31};
int fab;
cout<<"How much Days in Fab this year = "; cin>>fab;
int i=0;
int *ptr;
while(i<=11)
{
 fab=fab+months[i];
 ptr=&fab;
 i++;
}
cout<<"total Days this Year Will be = "<<fab;
getch();
}

output :-

Friday 13 December 2013

C++ Assignment For Air University Student



CS-161 Computer Programming— Fall 2013

BEE                                                    Assignment # 03                                     5th Dec, 2013

                                                Submission Date: 12th Dec, 2013
_____________________________________________________________________________

Q#1   Write a program to keep record of employees personal and payroll information in structure. You should take information of employee name, address, id, served years, and for how many hours he works per day and hourly rate. Think yourself if it needs some nested structure or simple structure. You are required to calculate monthly salary of all 30 employees. Add 20% of salary increment if an employee has over 2 years of experience.

Instructions:

         Do not copy paste
         Submit in hard copy in start of lab
         Copied assignments will be marked Zero
         Total Marks 10
         Late assignment will not be considered




Saturday 5 October 2013

C++ pointers practice if that no is that then do that!! with the help of point

#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

void main()
{
    int a,b;
    int *ptr;
    int result;
    cout<<"point checking program\n";
    cout<<"if first number is greater then second then ADD \n";
    cout<<"if second number is greater then first then ADD \n";

    cout<<"enter the two numbers:";
        cin>>a>>b;
        if(a>b)
        {
            result = a+b;
            ptr=&result;
        }
        else if(a<b)
        {
            result = a-b;
        ptr = &result;
        }
        else
        {
            cout<<"wrong answer";
        }
        cout<<"value of the result is "<<result;
        cin>>result;
}


c++ Counting Table in which u set limit where to count

#include <iostream>

using namespace std;
int main () {
    int x,a,m;
    cout<<"number for the table to count"<<endl; cin>>a;
    cout<<"pleas enter the limit for upto table to print"<<endl;
    cin>>m;
    for(int i =1;i<=m;i++)
    {
        cout<<a<<" X "<<i<<" = "<<a*i<<endl;
    }
    cout<<endl<<"XXXXXXXXXXXXXXXXXX"<<endl;
}


Saturday 14 September 2013

NO MORE ON BLOGGER

NOTICE


GUYS,
 http://programmingisbest.blogspot.com
is no more all data is automatically transfer to my latest blog

link of new site will be posted soon

stay tuned!!

 
Sorry for the change of link

Regards

Umar Javed
umar@hashmisaf.com

Monday 10 June 2013

Thank You bloggers

Hi Friends Thank You For seeing my Blog spot programs kindly follow me at twitter for any suggestions


website www.twitter.com/@umarjavedmalik


Kindly write programs Yourself , if You Copy paste my code its Against the Copyrights Laws and plagiarism factorz!!



My another blog Link is :- www.csharpisbest.blogspot.com
is another of mine blog..

Regards

Umar Javed Malik
umarjaved01@gmail.com

Tuesday 21 May 2013

C++ Subject Grading Policy in University



#include<iostream.h>
void main()
{
int q1,q2,q3,q4,q5,q6; int A1,A2,A3,A4,A5;
int *ptr;
{
    cout<<"\nxxxxQuizzesxxxx";
//best quizzes situation choose best of the 4
cout<<"\nEnter the 5 quizzes marks  = ";
cin>>q1>>q2>>q3>>q4>>q5;
{
    if(q1<q2 && q1<q3 && q1<q4 && q1<q5)
        {
        q6=q2+q3+q4+q5;
        ptr=&q6;
        }
    else if(q2<q1 && q2<q3 && q2<q4 && q2<q5)
        {
        q6=q1+q3+q4+q5;
        ptr=&q6;
        }
    else if(q3<q1 && q3<q2 && q3<q4 && q3<q5)
        {
        q6 = q1+q2+q4+q5;
        ptr = &q6;
        }
  else if(q4<q1 && q4<q2 && q4<q3 && q4<q5)
        {
        q6 = q1+q2+q3+q5;
        ptr = &q6;
        }
  else if(q5<q1 && q5<q2 && q5<q4 && q5<q3)
        {
        q6 = q1+q2+q3+q4;
        ptr = &q6;
        }
 }
    cout<<"\n best of the 4 quizzes marks are as under = "<<q6;
 }
 {

    {
     cout<<"\nxxxxAssignemntsxxxx";
    //best Assignemts situation choose best of the 4
    cout<<"\n\nEnter the 4 Assignments marks are = ";
    cin>>A1>>A2>>A3>>A4;
    {
        if(A1<A2 && A1<A3 && A1<A4)
        {
        A5=A2+A3+A4;
        ptr=&A5;
        }
        else if(A2<A1 && A2<A3 && A2<A4 )
        {
        A5=A1+A3+A4;
        ptr=&A5;
        }
        else if(A3<A1 && A3<A2 && A3<A4)
        {
        A5 = A1+A2+A4;
        ptr = &A5;
        }
        else if(A4<A1 && A4<A2 && A4<A3)
        {
        A5 = A1+A2+A3;
        ptr = &A5;
        }

    }
    cout<<"\n best of the 3 Assignents  marks are as under = "<<A5;
    }

    //to get the 20% weightage
    q6 = (q6/2);

     // to gett the 10% weigtage of the assignments then
     A5 = (A5/3);
    }

    cout<<"\nSo the average best of against the 10% of assignment is  = "<< A5;
    cout<<"\nSo the average best of against the 20% of Quizes is  = "<< q6;

    float mid;
    float final;

    cout<<"\nxxxxMid Teremxxxx";
    cout<<"\nPlease Enter the mid term marks = "; cin>>mid;
    cout<<"\nxxxxFinal Termxxxx";
    cout<<"\nPlease Enter the Final term marks = "; cin>>final;

    cout<<"\nxxxxCalculationsxxxx";
    float totl=A5+q6+mid+final;
    cout<<"\n\nYour Total Marks in subject are as under = "<<totl;

    if(totl>=86 && totl<=100){cout<<"You got A grade";}
    else if(totl>=78 && totl<=85){cout<<"You got B+ grade";}
    else if(totl>=72 && totl<=77){cout<<"You got B grade";}
    else if(totl>=66 && totl<=71){cout<<"You got C+ grade";}
    else if(totl>=60 && totl<=65){cout<<"You got C grade";}
    else if(totl>=50 && totl<=60){cout<<"You got C grade";}
    else if(totl>=0 && totl<=49){cout<<"You are Fail ";}
    else{cout<<"\nWrong marks result error ,try again thnx ";}
}

Sunday 28 April 2013

c++ program save the string in file and read the string from the file


  1. main()//programmingisbest.blogspot.com
  2. {
  1. char name[15];//programmingisbest.blogspot.com//programmingisbest.blogspot.com
  2. char telephn[10];//programmingisbest.blogspot.com//programmingisbest.blogspot.com
  3. char city[15],opt;
  4. ofstream xyz("nnn.dat");//programmingisbest.blogspot.com
  5. int rec =1;//programmingisbest.blogspot.com
  6. clrscr();
  7. if(!xyz)//programmingisbest.blogspot.com
  8. {
  9.  cout<<"file is not open";
  10.  exit(1);
  11. }
  12. opt='y';
  13. while(opt=='y' || opt=='Y')
  14. {
  15. cout<<"\n Enter the record no # : "<<rec;
  16. cout<<"\n Enter the name of the customer: ";
  17. cin>>name;
  18. cout<<"\n Enter the telephone no of the customer : ";
  19. cin>>telephn;
  20. cout<<"\n enter the city of the customer : ";
  21. cin>>city;
  22. xyz<<name<<"\t"<<telephn<<"\t"<<city<<endl;
  23. rec ++;
  24. cout<<"\n enter more record press (Y/n)";
  25. cin>>opt;
  26. }
  27. }














  1. #include<iostream.h>
  2. #include<fstream.h>
    1. #include<conio.h>
    2. #include<stdlib.h>
    3. main()
    4. {
    5. char name[15];//programmingisbest.blogspot.com
    6. char telephn[10];
    7. char city[15];//programmingisbest.blogspot.com
    8. int rec =1;
    9. ifstream xyz("nnn.dat");
    10. clrscr();//programmingisbest.blogspot.com
    11. if(!xyz)
    12. {
    13.  cout<<"file is not open";
    14.  exit(1);
    15. }
    16. while(xyz)
    17. {
    18. xyz>>name>>telephn>>city;//programmingisbest.blogspot.com
    19. cout<<"\nrecod no is # : "<<rec;//programmingisbest.blogspot.com
    20. cout<<"\nName is : "<<name;//programmingisbest.blogspot.com
    21. cout<<"\ntelephone no is : "<<telephn;
    22. cout<<"nCity is : "<<city;//programmingisbest.blogspot.com
    23. rec++;//programmingisbest.blogspot.com
    24. }
    25. }



Character Write adn Read Program in which character by character Data is saved to the file and then Read from the file in turboo 's bin folder

//program stores characters until escape key is not pressed

#include<iostream.h>
#include<fstream.h>
#include<conio.h>

void main()
{
char ch;
ofstream as("test.txt");
clrscr();
while(ch!=27)
{
ch = getche();
//obj.put(character);
as.put(ch);
if(ch=='\r')
cout<<endl;
}
}

//read character by character data from the file :D
//umarjaved01@gmail.com

#include<iostream.h>
#include<fstream.h>
#include<conio.h>

void main()
{
char ch;
ifstream as("test.txt");
clrscr();
while(as)
{
as.get(ch);
cout<<ch;
}
}


Monday 25 March 2013

C++ Sum of two numbers using pointers

#include<iostream.h>
void main(){
int n,m,*no,*mo;
no=&n;
mo=&m;
cout<<"Enter the two numbers";
cin>>*no>>*mo;
//*no=2;
//*mo=3;
cout<<"sum of two numbers via pointer is as under = "<<n+m;}



C++ program tell you the cube of the number entered by the user

#include<iostream.h>
 int main()
{int cube(int);
int a;
cout<<"Enter a number to find : ";
cin>>a;
cout<<"Cube of a number is as under : "<<cube(a);
return 0;}

int cube(int m)
{
int mx=m;
mx=mx*mx*mx;
return mx;
}



C++ simple pointer program tell you the address of the pointer


#include<iostream.h>
void main(){
int x,y;
x=245; y=246;
cout<<"value of variable = "<<x<<endl;
cout<<"Value of Address x = "<<&x<<endl;
cout<<"Value of Address y = "<<&y;

}


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++ Empty Square Program

 

#include <iostream.h>

int main()
{
    int row=6 , col;
    while (row >= 1)
    {
        col=11;
        while (col >= 1)
        {
            if (row==6 || row==1)
            {
                cout << "=";
            }
            if (row>=2 && row<=5)
            {
                if (col==1 || col==11)
                {
                    cout << "*";
                }
                else
                {
                    cout <<" ";
                }
            }
            col--;
        }
        row--;
        cout << endl;
    }
    return 0;
}

C++ Even & Odd Number Teller Program

 

 

#include<iostream.h>
void main()
{ int num;
cout<<"Enter the number to check weather its even or not = "; cin>>num;
if(num%2==0){cout<<"number is even";}
else if(num%3==0){cout<<"number is odd";}
else {cout<<"Try Again";}
}

C++ Factorial Simple Program


#include<iostream>
#include<conio.h>

using namespace std;

void main()
{
int fact;
int result= 1;

cout<<"Enter Number to find Factorial = "; cin>>fact;

int i=fact;  //i = 5
for(int i=fact;i>1;i--)
{
fact = fact * (i-1);
cout<<fact<<",";
}
_getch();

}



C++ Rectangle Program


#include <iostream.h>

int main()
{
    int row=1 , col;
    while (row <= 5)
    {
        col=12;
        while (col >= 1)
        {
            cout << "* ";
            col--;
        }
        cout << endl;
        row++;
    }
    return 0;
}

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();

}







C++ Half Diamond Program Using NEsted Loops



#include <iostream.h>

int main()
{
    int row=1 , col ;

    while(row <= 6)
    {
        col = row;
        while (col >= 1)
        {
            cout << "*";
            col--;
        }
        cout << endl;
        row++;
    }
    row=6;
    while (row >= 1)
    {
        col = row;
        while (col >=1)
        {
            cout << "*";
            col--;
        }
        cout << endl;
        row--;
    }
    return 0;
}

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

  1. #include<iostream.h>
  2. #include<conio.h>
  3. //www.programmingisbest.blogspot.com
  4. void main()
  5. {
  6. float x[5]; float cpa;
  7. char name[15],fname[15];  int i=1; int cr[5]; float result[5];
  8. cout<<"please enter your name: ";
  9. cin>>name;
  10. cout<<"please enter your father name:";
  11. cin>>fname;
  12. cout<<"please enter your previous cgpa = ";
  13. cin>>cpa;
  14. while(i<6)
  15. {//www.programmingisbest.blogspot.com
  16. cout<<"enter the marks of the subject"<<i<<" = ";
  17. cin>>x[i];
  18. cout<<"enter the credit hour of that subject = ";
  19. cin>>cr[i];
  20. result[i]=cr[i]*x[i];
  21. i++;
  22. }

  23. int gm;float sum; float gpa;
  24. gm=cr[1]+cr[2]+cr[3]+cr[4]+cr[5];
  25. sum = result[1]+result[2]+result[3]+result[4]+result[5];
  26. gpa=sum/gm;
  27. cout<<"\n\n\n\n";
  28. cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"; cout<<"xxxR.E.S.U.L.Txxx\n";   cout<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
  29. cout<<"Your gpa is as under = "<<gpa<<endl; float kk; kk=(gpa*cpa)/2; cout<<"your cgpa is as under = "<<kk<<endl;
  30. if(kk>2 && kk<4)
  31. {
  32. cout<<"You are Qualified";
  33.  }
  34.  else if(kk<2 && kk>1.5)
  35.   {
  36.   cout<<"You are Probiation";
  37.     }
  38.     else if(kk<1.5)
  39.     {
  40.     cout<<"You are at chance";
  41.     }
  42.     else {
  43.     cout<<"try again";
  44.      }
  45. getch();
  46. }

C++ program tell you the size of String which You have entered



#include<iostream.h>
#include<conio.h>
#include<cstring.h>


void main()
{
    char arr[20];
    int a,count;

    count=0;

    cin.getline(arr,20,'\n');

    for(a=0;a<20;a++)
    {
        if(arr[a]!='\0')
        {
            count++;

        }
        else if(arr[a]=='\0')
        {
            break;
        }
    }

    cout<<"\n\nThe size is = "<<count;

    getch();
}

using C++ structure call the paramters to make Calculator program



#include<iostream.h>

struct dis
{
 int num; int num2;
};

void main()
{
dis x,y;
 cout<<"enter the first number & second number = ";
  cin>>x.num>>y.num2;
 cout<<"\nadd = "<<x.num+y.num2;
 cout<<"\nsub = "<<x.num-y.num2;
 cout<<"\nMultiply = "<<x.num*y.num2;
 float g; g=x.num/y.num2;
 cout<<"\nDivide = "<<g;
}

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);
  }