Results 1 to 2 of 2

Thread: Example for C++ begniers(conditional)...

  1. #1
    appteach is offline Junior Member
    Last Online
    18th February 2016 @ 05:33 PM
    Join Date
    01 Feb 2016
    Age
    28
    Gender
    Male
    Posts
    13
    Threads
    4
    Credits
    0
    Thanked
    2

    Thumbs up Example for C++ begniers(conditional)...


    pahly khud try kejye ga phr solution dekhye ga
    _______________________________
    /*write a program that input salary and grade. It adds 50% bonus if grade
    is greater than 15. it adds 25% bonus if the grade is 15 or lesss and then
    displays thye total salary */

    #include <iostream>
    #include <conio.h>
    using namespace std;
    int main()
    {
    float bonus,total_salary;
    int grade,salary;
    cout<<"Enter your salary:";
    cin>>salary;
    cout<<"Enter your grade:";
    cin>>grade;
    if(grade>15)
    bonus=salary*50.0/100.0;
    else
    bonus=salary*25.0/100.0;
    total_salary=salary+bonus;
    cout<<"your total salary is RS:"<<total_salary;
    return 0;

    }

  2. #2
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 10:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Thanked
    5

    Default

    Apptech, ap acha kr rhy ho, mgr ya program dakho zayda bhtr hy...

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
    	int salary, bonus;
    	double total_salary, grade;
    	char again;
    
    	do
    	{
    		cout << "Please enter your salary:- RS";
    		cin >> salary;
    		cout << "Now, enter your grade also:- ";
    		cin >> grade;
    		
    		if (grade > 15)
    		{
    			bonus = salary * (50.0/100.0);
    		}
    
    		else
    		{
    			bonus = salary * (25.0/100.0);
    		}
    
    		total_salary = salary + bonus;
    
    		cout << "Your total salary with your bonus is:- RS" << total_salary << endl;
    
    		cout << "Do you want to use this program again?\n";
    		cout << "Type Y for yes and N for no\n";
    		cin >> again;
    	} while ( (again == 'y') || (again == 'Y') );
    
    	cout << "End of program\n";
    
    	return 0;
    }

Similar Threads

  1. Class # 2.1 => Conditional Statement
    By Abdul Moeed in forum C++
    Replies: 75
    Last Post: 1st February 2016, 01:53 PM
  2. conditional call forwarding active
    By faizan374 in forum Ask an Expert
    Replies: 1
    Last Post: 17th September 2015, 09:31 PM
  3. Conditional FOrmatting & conver
    By ahmedalish in forum Ask an Expert
    Replies: 0
    Last Post: 29th June 2015, 01:18 PM
  4. plz help to deactive conditional call forwarding from ufone sim
    By ZEROPOINT in forum Mobile phones problems and Help Zone
    Replies: 5
    Last Post: 24th September 2013, 09:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •