I have 2 variables c and 103.5 so now I want to assign 103.5 to c so when people write c It out puts as 103.5?
Assuming that c is of type double, 103.5 will not truncate when assigning it. However, assigning a floating-point numerical value to an int, short, or long will cause the value to truncate, reducing the value to 103.
Ok now the next thing is, how can i enter like 2 values in the same line means, like if i want the use r to enter c than d in the same line so like how do i write a program for that>
The only difference is that y does not change if x changes.
y = x * x; // y is 16
x = 5; //y still equals 16
y = x*x; // y is now 25
If you understand this, programming becomes much easier. The same thing applies to classes, etc. however different rules apply to different things. This is just the basic concept of it.
My bad so this is the problem, ok so I have to ask user to enter C and D, but in one line. so The program outptus please enter C and D, and the user will enter c and D but int he same line.
If you didn't get ^. You know how the user normally enter one variable at a time in programming like either the value or name. But this time the user has to enter 2 at once.
You can use getline() which you can use to fetch a line from the cin stream. You'll have to parse it yourself or you can use the delimiter if I'm not mistaken.
no not string here i tried to write the program but it is wrong, but should give you the idea, what i want.
// Menu Chooser
// Demonstrates the switch statement
#include <iostream>
#include <string>
#include<stdlib.h>
#include<windows.h>
using namespace std;
int main()
{
double C=0.0;
string name="";
char choice=' ';
int count=0;
do
{
cout << "WElCOME TO THE song program"<<endl;
cout << "A - SONG 1 "<<endl;
cout << "B - Temporarily Unavilable"<<endl;
cout << "C - Calculate area of Parallelogram"<<endl;
cout << " Your Choice: ";
cin >> choice;
if(choice=='a')
choice='A';
if(choice=='b')
choice='B';
if(choice=='c')
choice='C';
switch (choice)
{
case 'A':
cout << "You picked Son no.1"<<endl;
// input data
do
{
count = count + 1;
cout << "The first key is C, Please enter C"<< endl;
cin >> Beep(103.5,1000);
if (C=="C")
cout<<"You entered the wrong note please try again"<<endl;
// Menu Chooser
// Demonstrates the switch statement
#include <iostream>
#include <string>
#include<stdlib.h>
#include<windows.h>
using namespace std;
int main()
{
double C=0.0;
string name="";
char choice=' ';
int count=0;
C=103.5;
do
{
cout << "WElCOME TO THE song program"<<endl;
cout << "A - SONG 1 "<<endl;
cout << "B - Temporarily Unavilable"<<endl;
cout << "C - Calculate area of Parallelogram"<<endl;
cout << " Your Choice: ";
cin >> choice;
if(choice=='a')
choice='A';
if(choice=='b')
choice='B';
if(choice=='c')
choice='C';
switch (choice)
{
case 'A':
cout << "You picked Son no.1"<<endl;
// input data
do
{
count = count + 1;
cout << "The first key is C, Please enter C"<< endl;
cin >> Beep(C,1000);
if (C=="C")
cout<<"You entered the wrong note please try again"<<endl;
Maybe scanf( )[1] can help you. In Visual C++ Express 2010, the compiler warns you that scanf( ) is deprecated, and encourages you to use scanf_s( ) instead.
Here's an example that uses scanf( ):
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
int main( )
{
int one( 0 ), two( 0 );
std::scanf( "%d %d", &one, &two );
std::cout << one << " " << two << std::endl;
return 0;
}