Tuesday, 26 July 2016

C++ GPA CALCULATOR

Step # 1 

first you have to view my previous program that is basic C++ GPA calculator available on following link

C++ GPA Calculator

Step # 2

this program is consists of following attributes.
1) pointer array.
2) function call by value & inline function.

i dont want to describe program briefly this program is consisted of  question as under

User is asked to enter 3 subject marks out of 100 

marks greater then 88 but less then 100 award grade must be A with 4.00 points
marks greater then 80 but less then 87 award grade must be B+ with 3.50 points
marks greater then 73 but less then 79 award grade must be B with 3.00 points
marks greater then 66 but less then 72 award grade must be C+ with 2.50 points
marks greater then 60 but less then 66 award grade must be C with 2.00 points
marks greater then 50 but less then 59 award grade must be D with 4.00 points
else you are fail in course

according to above brief option logic is simple 


Code:-


#include<iostream>

#include<conio.h>

using namespace std;



float getGpa(float *marks,float *subjects)

{
float result = 0;

for (int i = 0; i < 3; i++)
{
float points = 0;
if ((*marks + i)>=87)
{
points = 4;
}
else if ((*marks + i) >= 80 && (*marks + i) < 87)
{
points = 3.5;
}

else if ((*marks + i)>=72 && (*marks + i) < 80)

{
points = 3.0;
}
else if ((*marks + i)>=66 && (*marks + i) < 72)
{
points = 2.5;
}
else if ((*marks + i) >= 60 && (*marks + i) < 66)
{
points = 2.0;
}
else
{
points = 0;
}


result += points;

}

float ab;

ab = (result / 3);
return ab;
}


void main()

{
float marks[3];
float credits[3];
float *ptr;
float *_ptr;
for (int i = 0; i < 3; i++)
{
cout << "Enter marks of subject number " << i << " = ";
cin >> marks[i];

cout << "Enter credit of subject number " << i << " = ";
cin >> credits[i];
}

ptr = marks; _ptr = credits;

cout << "Gpa is = " << getGpa(ptr, _ptr);
_getch();
}


OUTPUT





ALL RIGHTS RESERVED TO UMAR JAVED 

c# , c++ , WORDPRESS , XAMARIN DEVELOPER

Friday, 10 October 2014

C++ Left Lower Pattern Staric Traingle nested loop program

void main()

{

int size=3;
cin>>size;
int margin_space;
int row=size;
while(row>=0)
{
margin_space = size - row;
int col = 0;
while(col<margin_space)
{
cout<<" ";
col = col+1;
}
int starics = row;
while(starics>=0)
{
cout<<"X";
starics--;
}
cout<<endl;
row--;
}

}



output:-



c++ print left triangle upper portion

void main()
{
int size=3;
        cout<<"please enter the size of triangle to print";
cin>>size;
int margin_space;
int row=1;
while(row<=size)
{
margin_space = size - row;
int col = 0;
while(col<margin_space)
{
cout<<" ";
col = col+1;
}
int starics = 1;
while(starics<=row)
{
cout<<"X";
starics++;
}
cout<<endl;
row++;
}
}


output:-




C++ check entered string if repeated same character in string again "Taaseep" then show output it as "tasep" program





void main()
{
   string a = "azzfghk";

int i=0;
while(i<a.length())
{
if(a[i]==a[i+1])
{
cout<<a[i];
i=i+2;
}
else
{
cout<<a[i];
i++;
}
}
}

Friday, 25 July 2014

C++ Check Whether entered numbers are even or not

Purpose of the program is basically understanding that the entered various amount of numbers by user and test whether all of them are verifies that they are even number or not and how we check each number by using loop , what is the purpose to use loop why i use it ? efficient + reliable and deep understanding of concept make it possible to do efficient and complex less logic to easily understand program



Hope You will enjoy to do programming ....!

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



int main()
{
int num1,num2,num3,num4;

for(int i=0;i<4;i++)
{
cout<<"Please Enter the number = "<<i<<" = ";
if(i==0){cin>>num1;}
else if(i==1){cin>>num2;}
else if(i==2){cin>>num3;}
else cin>>num4;
}

//cout<<"You have Entered the numbers are as under \n "<<num1<<"\n then = "<<num2<<"\n then = "<<num3<<"\n then ="<<num4<<endl;

cout<<"\n\t----Results-----";
cout<<"\n\t----Even or Odd-----";
cout<<"\n\n";
int i=0;
while(i<4)
{
if(i==0)
{
if(num1%2 == 0){ cout<<"Entered First number is even = "<<num1<<endl;}
else
cout<<"Entered First number is not even = "<<num1<<endl;
}

if(i==1)
{
if(num2%2 == 0){ cout<<"Entered second number is even = "<<num2<<endl;}
else
cout<<"Entered second number is not even = "<<num2<<endl;
}
if(i==2)
{
if(num3%2 == 0){ cout<<"Entered third number is even = "<<num3<<endl;}
else
cout<<"Entered third number is not even = "<<num3<<endl;
}
if(i==3)
{
if(num4%2 == 0){ cout<<"Entered Fourth number is even = "<<num4<<endl;}
else
cout<<"Entered Fourth number is not even = "<<num4<<endl;
}
i++;
}


getch();
return 0;
}