Code:
//A program that calculates the reduced mass of diatomic molecules.
//The following libraries will be used.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
Manual_Input()
{
}
Textfile_Input()
{
}
int main()
{
int selection;//Defines the variable used to decide on a keyboard or text file input.
selection=4;//Sets the value of the variabe selection so it can be used for the do while loop.
do {
printf("A program to calculate the reduced mass of diatomic molecules.\n");//Intro Message.
Data_input://Allows the program to loop if the user selects a value other than 1,2, or 3.
printf("Input data from the keyboard, from a text\nfile, or close the program?\n");
printf("1. From the keyboard.\n");printf("2. From a text file.\n");printf("3. Close program.\n");printf(":");
scanf("%d",&selection);//Allows the user to choose whether or not to input from a text file or the keyboard.
if (selection==1)
{
printf("Hello");
}
if (selection==2)
{
printf("how are you?");
}
if (selection!=1 || selection!=2 || selection!=3)
{
printf("Invalid Option, please choose again. ");
}
} while (selection!=1 || selection!=2 || selection!=3);
return 0;
}
I've changed the code to this, and also set the value of the selection variable so it has a different value to that of 1, 2 or 3.
Code:
int selection;//Defines the variable used to decide on a keyboard or text file input.
selection=4;//Sets the value of the variabe selection so it can be used for the do while loop.
However the loop doesn't seem to be working. Even when I set the value to 1, 2 or 3 the loop repeats.