can u please scan my program , it wont run. the objective is to identify the type of student by answering the questions by yes or no:crazy: and i cant find the prob., i think it is the conditions.:cryin: Code: #include<stdio.h> int a,b,c,d,e,f,g,h,i,j;:cryin: main() { clrscr(); printf("This Program Tells What Kind Of Person You Are"); printf("Kindly answer all the questions that follow after this message"); printf("press '1' for YES\n press '2' for a NO\n"); clrscr(); printf("/nDo you often smile?"); scanf("%d",&a); clrscr(); printf("\n\nCan you solve difficult math problems in 3 minutes?"); scanf("%d",&b); clrscr(); printf("\n\nDo you have many friends?"); scanf("%d",&c); clrscr(); printf("\n\nDo you like sports?"); scanf("%d",&d); clrscr(); printf("\n\nDOTA first before assignment?"); scanf("%d",&e); clrscr(); printf("\n\nDo you have jokes?"); scanf("%d",&f); clrscr(); printf("\n\nIs your head bangin' while listening loud music?"); scanf("%d",&g); clrscr(); printf("\n\nWould you rather play 'GUITAR HERO' than 'CHESS'?"); scanf("%d",&h); clrscr(); printf("\n\nDo you run on your way to school just to be on time?"); scanf("%d",&i); clrscr(); printf("\n\nDo you believe in saying,'try and try until you succeed?'"); scanf("%d",&j); clrscr(); if (a<1) (a>2) (b<1) (b>2) (c<1) (c>2) (d<1) (d>2) (e<1) (e>2) (f<1) (f>2) (g<1) (g>2) (h<1) (h>2) (i<1) (i>2) (j<1) (j>2) printf("Program Error"); else if (b==1) (i==1) (j==1) (e==2) (h==2) printf("You're a Genius\nYou have an exceptional thinking ability that others don't."); else if (c==1) (e==1) (g==1) (h==1) (b==2) (i==2) printf("You're a Rockstar\nKeep on Rockin' and don't forget lovin'!"); else if (c==1) (d==1) (i==1) (j==1) (b==2) (f==2) printf("You're an Atlhete!\nKeep on practicing to succeed."); else if (a==1) (c==1) (e==1) (f==1) (b==2) (i==2) (j==2) (h==2) printf("Cool...you're a Happy-go-Lucky Person!\nAlways thinkin' positive,but always consider the future."); else if (a==2) (c==2) (d==2) (f==2) (i==2) (j==2) printf("You're an Emo!\nTry looking at the bright side of all things and try not to hurt yourself..."); else printf("You're a Simple Person!\nRemember:'the simpler, the better'."); getch(); }
The problem is in the if and else if conditions . Code: if ( (a<1) && (a>2) && (b<1) && etc ..) You should have the logical operators to check all the possible conditions .Do the same for the else if condition also .
Done i have just Done the problem you were getting but i have done it in c++ Here i give you the code but u need to change it in c by urself Code: #include<iostream> using namespace std; int a,b,c,d,e,f,g,h,i,j; int main() { cout<<"This Program Tells What Kind Of Person You Are"; cout<<"Kindly answer all the questions that follow after this message"; cout<<"press '1' for YES\n press '2' for a NO\n"; cout<<"\nDo you often smile?"; cin>>a; cout<<"\n\nCan you solve difficult math problems in 3 minutes?"; cin>>b; cout<<"\n\nDo you have many friends?"; cin>>c; cout<<"\n\nDo you like sports?"; cin>>d; cout<<"\n\nDOTA first before assignment?"; cin>>e; cout<<"\n\nDo you have jokes?"; cin>>f; cout<<"\n\nIs your head bangin' while listening loud music?"; cin>>g; cout<<"\n\nWould you rather play 'GUITAR HERO' than 'CHESS'?"; cin>>h; cout<<"\n\nDo you run on your way to school just to be on time?"; cin>>i; cout<<"\n\nDo you believe in saying,'try and try until you succeed?'"; cin>>j; if( a<1 && a>2 && b<1 && b>2 && c<1 && c>2 && d<1 && d>2 && e<1 && e>2 && f<1 && f>2 && g<1 && g>2 && h<1 && h>2 && i<1 && i>2 && j<1 && j>2 ); { cout<<"Program Error"; getchar(); } if( b==1 && i==1 && j==1 && e==2 && h==2) { cout<<"You're a Genius\nYou have an exceptional thinking ability that others don't."; getchar(); } if (c==1 && e==1 && g==1 && h==1 && b==2 && i==2) { cout<<"You're a Rockstar\nKeep on Rockin' and don't forget lovin'!"; getchar(); } if ( c==1 && d==1 && i==1 && j==1 && b==2 && f==2) { cout<<"You're an Atlhete!\nKeep on practicing to succeed."; getchar(); } if ( a==1 && c==1 && e==1 && f==1 && b==2 && i==2 && j==2 && h==2) { cout<<"Cool...you're a Happy-go-Lucky Person!\nAlways thinkin' positive,but always consider the future."; getchar(); } if (a==2 && c==2 && d==2 && f==2 && i==2 && j==2) { cout<<"You're an Emo!\nTry looking at the bright side of all things and try not to hurt yourself..."; getchar(); } else { cout<<"You're a Simple Person!\nRemember:'the simpler, the better'."; getchar(); } getchar(); return 0; } but there is still problem in this statement tell me what? Code: if( a<1 && a>2 && b<1 && b>2 && c<1 && c>2 && d<1 && d>2 && e<1 && e>2 && f<1 && f>2 && g<1 && g>2 && h<1 && h>2 && i<1 && i>2 && j<1 && j>2 ); { cout<<"Program Error"; getchar();
Why you end up the if statement by ';'. Code: if( a<1 && a>2 && b<1 && b>2 && c<1 && c>2 && d<1 && d>2 && e<1 && e>2 && f<1 && f>2 && g<1 && g>2 && h<1 && h>2 && i<1 && i>2 && j<1 && j>2 )[COLOR="Red"];[/COLOR] // Error Remove the ';' and try .