0% found this document useful (0 votes)
48 views

Program For Table

The document contains the code for several C++ programs that demonstrate basic concepts like: 1. A math tables program that allows the user to input values to calculate and display multiplication tables. 2. A grading program that takes a mark as input and outputs the corresponding grade based on ranges. 3. An electricity bill calculator that determines the bill amount based on the consumed units. 4. A program to calculate the area of a triangle using inputs for the three sides and the formula. 5. A simple greeting program to print messages to demonstrate a basic C++ program.

Uploaded by

hissanbinafzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Program For Table

The document contains the code for several C++ programs that demonstrate basic concepts like: 1. A math tables program that allows the user to input values to calculate and display multiplication tables. 2. A grading program that takes a mark as input and outputs the corresponding grade based on ranges. 3. An electricity bill calculator that determines the bill amount based on the consumed units. 4. A program to calculate the area of a triangle using inputs for the three sides and the formula. 5. A simple greeting program to print messages to demonstrate a basic C++ program.

Uploaded by

hissanbinafzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PROGRAM FOR TABLE

// Math Tables
#include<iostream>
#include<conio.h>
using namespace std;
int main(void)
{
int a,b,c,s,e,g;
char r;
cout<<"\n\t PROGRAM FOR TABLES";
start:
cout<<"\n\n\t Which Table? ";
cin>>a;
cout<<"\n\t Starting Value? ";
cin>>s;
cout<<"\n\t Ending Value? ";
cin>>e;
cout<<"\n\t Gap Value? ";
cin>>g;
for (b=s; b<=e; b=b+g)
{
c=a*b;
cout<<"\n\t "<<a<<" X "<<b<<" = "<<c;
}
cout<<"\n\t........................";
cout<<"\n\n\t Do you want to solve for another problem?";
jump:
cout<<"\n\t Press y for yes and n to end the program ";
cin>>r;
if (r=='y'|| r=='Y')
{
goto start;
}
else if (r=='n' ||r=='N')
{
cout<<"\n\t Program End";
}
else
{
cout<<"\n\t You have given an invalid input";
goto jump;
}
getche();
return(0);
}
GRADING PROGRAM

// Grading Program
#include<iostream>
#include<conio.h>
using namespace std;
int main(void)
{
cout<<"\n\t GRADING PROGRAM";
int x;
char r;
start:
cout<<"\n\n\t Enter Your Marks =";
cin>> x;
if (x<=100)
{
if (x>=90)
{
cout<<"\n\t Your Grade is A+";
}
else if (x>=80)
{
cout<<"\n\t Your Grade is A";
}
else if (x>=70)
{
cout<<"\n\t Your Grade is B+";
}
else if (x>=60)
{
cout<<"\n\t Your grade is B";
}
else if (x>=50)
{
cout<<"\n\t Your Grade is C";
}
else if (x<50)
{
cout<<"\n\t Sorry! You have not succeeded";
}
}
else
{
that:
cout<<"\n\t Your input is incorrect";
goto start;
}
cout<<"\n\n\t Do you want to solve for another problem?";
jump:
cout<<"\n\t Press y for yes and n to end the program ";
cin>>r;
if (r=='y'|| r=='Y')
{
goto start;
}
else if (r=='n' ||r=='N')
{
cout<<"\n\t Program End";
}
else
{
cout<<"\n\t You have given an invalid input";
goto jump;
}
getche();
return(0);
}

























PROGRAM TO CALCULATE ELECTRICITY BILL

// Electricity Bill Program
#include<iostream>
#include<conio.h>
using namespace std;
int main(void)
{
int u;
float bill;
char r;
cout<<"\n\t PROGRAM TO CALCULATE ELECTRICITY BILL";
start:
cout<<"\n\n\t Enter Consumed Units =";
cin>> u;
if (u<=50)
{
// For less than 50 units
bill=u*4;
}
else if (u<=300)
{
// More than 50 and less than 300 units
bill=(u-50)*5+200;
}
else if (u<=500)
{
// More than 300 and less than 500 units
bill=(u-300)*6+1450;
}
else if (u<=850)
{
// More than 500 and less than 850 units
bill=(u-500)*8+2650;
}
else if (u<=1000)
{
// More than 850 and less than 1000 units
bill=(u-850)*10+5450;
}
else if (u>1000)
{
// More than 1000 units
bill=(u-1000)*12+6950;
}
cout<<"\n\t Total Consumed Units are "<<u;
cout<<"\n\t Total Bill Amount is Rs "<<bill;
cout<<"\n\n\t Do you want to solve for another problem?";
jump:
cout<<"\n\t Press y for yes and n to end the program ";
cin>>r;
if (r=='y'|| r=='Y')
{
goto start;
}
else if (r=='n' ||r=='N')
{
cout<<"\n\t Program End";
}
else
{
cout<<"\n\t You have given an invalid input";
goto jump;
}
getche();
return(0);
}























PROGRAM TO CALCULATE AREA OF TRIANGLE

// Area of Triangle
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main(void)
{
cout<<"\n\t PROGRAM TO CALCULAE AREA OF TRIANGLE";
unsigned int a,b,c;
char r;
float s, ar, area;
start:
cout<<"\n\n\t Enter value of a =";
cin>>a;
cout<<"\n\t Enter value of b =";
cin>>b;
cout<<"\n\t Enter value of c =";
cin>>c;
s= (a+b+c)/2;
ar= s*(s-a)*(s-b)*(s-c);
area= pow(ar,0.5);
cout<<"\n\t Value of s is "<<s;
cout<<"\n\t Value of area is "<<area<<"cm2";
cout<<"\n\n\t Do you want to solve for another problem?";
jump:
cout<<"\n\t Press y for yes and n to end the program ";
cin>>r;
if (r=='y'|| r=='Y')
{
goto start;
}
else if (r=='n' ||r=='N')
{
cout<<"\n\t Program End";
}
else
{
cout<<"\n\t You have given an invalid input";
goto jump;
}
getche();
return(0);
}

GREETING PROGRAM

// Greeting Program
#include<iostream>
#include<conio.h>
using namespace std;
int main(void)
{
cout<<"\n\t This is our First Class";
cout<<"\n\t We are working with C++";
getch();
return(0);
}



































Assignment
COMPUTER SCIENCE & PROGRAMMING
LAB
Submitted To
SIR MMA BHUTTA
Submitted By
HISSAN BIN AFZAL
2008-IME/2010-ME-257


University of Engineering & Technology
Lahore

You might also like