hello guys:::

how to print a multiplication table of 2,3 ,4 or any table using functions in c++.. ??? Can anybody solve this please....

Remember using "Functions" e.g Multiplication(int x)

{ }

int main{

then call the function}

how to print a multiplication table of 2,3 ,4 or any table using functions in c++.. ??? Can anybody solve this please....

Remember using "Functions" e.g Multiplication(int x)

{ }

int main{

then call the function}

Last edited on

Thank you so much for your kind help.. it works now,,,, thank youuu.... but the same problem in the below program also,, what to do?

#include <iostream>

#include<string>

#include<cmath>

using namespace std;

int main()

{

int b,c,d,e=0,total=300, sum=0.0;

float percentage=0;

string a;

cout<<"******Welcome to the Student Grading Calculation System******" <<endl;

cout<<"\n";

cout<< "Do you want to Calculate your Grades?"<<endl;

cout<<"Enter y for yes or n for no" <<endl;

while(e<5){

cin>> a;

if(a=="y"){

cout<<"Enter your Math Marks \n";

cin>> b;

cout<<"Enter your Science Marks \n";

cin >> c;

cout<<"Enter your English Marks \n";

cin>> d;

sum = b+c+d;

cout<< "your Obtained marks are = " << sum <<endl;

percentage = sum*100/total;

cout << "Percentage = " << percentage << "%" << endl;

cout<<"\n";

cout<<"Do you want Further Calculation of your Grades ? " << endl;

e++;

}else {

if(a=="n"){

cout <<"Thank you so much for using Student Calculation System " << endl;

return 1;

}}

}

return 0;

}

#include <iostream>

#include<string>

#include<cmath>

using namespace std;

int main()

{

int b,c,d,e=0,total=300, sum=0.0;

float percentage=0;

string a;

cout<<"******Welcome to the Student Grading Calculation System******" <<endl;

cout<<"\n";

cout<< "Do you want to Calculate your Grades?"<<endl;

cout<<"Enter y for yes or n for no" <<endl;

while(e<5){

cin>> a;

if(a=="y"){

cout<<"Enter your Math Marks \n";

cin>> b;

cout<<"Enter your Science Marks \n";

cin >> c;

cout<<"Enter your English Marks \n";

cin>> d;

sum = b+c+d;

cout<< "your Obtained marks are = " << sum <<endl;

percentage = sum*100/total;

cout << "Percentage = " << percentage << "%" << endl;

cout<<"\n";

cout<<"Do you want Further Calculation of your Grades ? " << endl;

e++;

}else {

if(a=="n"){

cout <<"Thank you so much for using Student Calculation System " << endl;

return 1;

}}

}

return 0;

}

remember this rule:

If you want something to be returned as a float, first of all initialize it as float, i.e 0.0 and not 0.

Second when you are doing sum*100/total, and you want a float , do like this

sum*100.0/float.

Finally if you want floats use floats otherwise use ints.

If you want something to be returned as a float, first of all initialize it as float, i.e 0.0 and not 0.

Second when you are doing sum*100/total, and you want a float , do like this

sum*100.0/float.

Finally if you want floats use floats otherwise use ints.

Topic archived. No new replies allowed.