Problem is when i press B as the center element the line at the end "if(centerelement=="B") should run what inside.
I put this inside the if statement:
Code:
VEC = 3;
printf("%d",VEC);
I put the printf so i can verify that the value of VEC is now 3.
Here is the source code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char charselect[1];
int select;
char tempelement[3];
char centerelement[3];
char pelement1[3]; //periferal element 1
char pelement2[3]; //periferal element 2
char pelement3[3]; //periferal element 3
char pelement4[3]; //periferal element 4
int totalVE; //total valance electrons
int VEC; //# of valance electrons in center
int VE1;
int VE2;
int VE3;
int VE4;
/* H = 1;
B = 3;
C = 4;
N = 5;
P = 5;
O = 6;
S = 6;
Se = 6;
F = 7;
Cl = 7;
Br = 7;
I = 7;
*/
printf("What is the structure of the Lewis Structure?\n\n");
printf("1 - Tetrahedral\n\n");
printf("Input corresponding number: ");
gets (charselect);
select = atoi(charselect);
if (select == 1)
{
printf("You selected Tetrahedral.\n\n");
printf("What is the center Element? \n");
scanf("%s",centerelement);
printf("What is the 1st periferal element? \n");
scanf("%s",pelement1);
printf("What is the 2nd periferal element? \n");
scanf("%s",pelement2);
printf("What is the 3rd periferal element? \n");
scanf("%s",pelement3);
printf("What is the 4th periferal element? \n");
scanf("%s",pelement4);
if(centerelement=="B")
{
VEC = 3;
printf("%d",VEC);
}
printf("%s %s %s %s %s", centerelement, pelement1, pelement1, pelement1, pelement1);
}
}