Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C
 #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{

    printf("welcome user\n");
printf("\n");
  printf("please answer this following questions\n");
  printf("\n");
    printf("choose your gender \n");
    printf("entre one (1) for male and");
    printf(" entre twoo (2) for female");
    printf("\n");
    printf("\n");
  
  
  int gender;
  char (male);
  char (female);
  scanf("%d", &gender);
printf("\n");
  if (gender = 1) {
    printf("your gender is %d", gender);
 
    printf(" (male)");
    printf("\n");

      printf("what is your age?\n");
  printf("\n");

    int age;

    scanf("%d", &age);
printf("\n");
    printf("your age is %d\n", age);
  printf("\n");

    if (age <= 30){ 
        printf("you are yong so live alife you will remember\n ");
      printf("\n");
  } 
    else if (age > 30) {
        printf("you are to old mf\n ");
       printf("\n");
        printf("but it's ok you still human\n");
      printf("\n");
        printf("XD\n");
      printf("\n");
      printf("\n");
    }


  printf("Rate your beauty from 10\n");
  printf("\n");
    int beauty;
  
      scanf("%d", &beauty);
   printf("\n");
  printf("so your beauty is %d\n", beauty);
  printf("\n");
  printf("you are ugly as f*** bro buts its ok we're all the same");

   
 
    }
  else if (gender = 2 )
    {
      printf("your gender is %d", gender);
      printf(" (female)");
      printf("\n");
      printf("what is your age?\n");
  printf("\n");

    int age;

    scanf("%d", &age);
printf("\n");
    printf("your age is %d\n", age);
  printf("\n");

    if (age <= 20){ 
  printf("you are yong i like that yoy are my type\n ");
      printf("\n");
  } 
    else if (age > 30) {
        printf("you still yong tho\n ");
       printf("\n");
       
    }


  printf("Rate your beauty from 10\n");
  printf("\n");
    int beauty ;
  
      scanf("%d", &beauty);
   printf("\n");
  printf("so your beauty is %d\n", beauty);
  printf("\n");

  if (beauty <= 7){
    printf("you are ugly bitch\n");
    printf("\n");
} 
  
  else if (beauty > 7)
      {
        printf("emmm i see you are so beautiful\n");
        printf("\n");
        
                                         } 

    printf("would you merry me?\n");
    printf("\n");
    int marry ;
    scanf("%d", &marry);
    char yes;
    char no;
    if (marry = yes) 
    
    printf("omg finelly i've got a wife for me\n");
    
    else if (marry = no)
  
  printf("it's ok i know that im ugly XD\n");
  }
}


What I have tried:

I tried to separate the answers of males from females
Posted
Updated 24-Feb-22 14:18pm
v2
Comments
PIEBALDconsult 24-Feb-22 17:16pm    
Here's a problem, think about it:
if (gender = 1)
if (gender = 2 )

In C, there is no "true" or "false" value - any nonzero value is true, and any zero value is false.
And the assignment operator "=" returns a value, so you can string them together:
C
a = b = c = 0;

So when you write an if statement, if the condition statement evaluates to a non-zero value - any non zero value - then the following line(s) of code will be executed.

And "=" is the assignment operator, while "==" is the equality comparison operator.

So look at your code, and see what you have used ... :D

To be honest, if you had used the debugger, you would have spotted that in a minute or maybe two and saved yourself a lot of time. It's well worth getting used to it as it's one of the best tools in a developers toolbox, and we all use it a lot. Get used to it on trivial projects like this and it'll stand you in good stead when you get to more complex ones.
 
Share this answer
 
Comments
PIEBALDconsult 24-Feb-22 19:39pm    
There are they who need Yoda-code. :(
CPallini 25-Feb-22 2:22am    
5.
Quote:
When I run my code and entre 2 it answer me like I entre 1 and I dont know why

C++
if (gender = 1) {  //Here, you store value 1 in gender
if (gender == 1) { //Here, you compare gender with value 1


Advice: Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
C++
#include <stdio.h>

#include <stdlib.h>

#include <stdbool.h>

int main() {

  printf("welcome user\n");
  printf("\n");
  printf("please answer this following questions\n");
  printf("\n");
  printf("choose your gender \n");
  printf("entre one (1) for male and");
  printf(" entre twoo (2) for female");
  printf("\n");
  printf("\n");

  int gender;
  char(male);
  char(female);
  scanf("%d", & gender);
  printf("\n");
  if (gender = 1) {
    printf("your gender is %d", gender);

    printf(" (male)");
    printf("\n");

    printf("what is your age?\n");
    printf("\n");

    int age;

    scanf("%d", & age);
    printf("\n");
    printf("your age is %d\n", age);
    printf("\n");

    if (age <= 30) {
      printf("you are yong so live alife you will remember\n ");
      printf("\n");
    } else if (age > 30) {
      printf("you are to old mf\n ");
      printf("\n");
      printf("but it's ok you still human\n");
      printf("\n");
      printf("XD\n");
      printf("\n");
      printf("\n");
    }

    printf("Rate your beauty from 10\n");
    printf("\n");
    int beauty;

    scanf("%d", & beauty);
    printf("\n");
    printf("so your beauty is %d\n", beauty);
    printf("\n");
    printf("you are ugly as f*** bro buts its ok we're all the same");

  } else if (gender = 2) {
    printf("your gender is %d", gender);
    printf(" (female)");
    printf("\n");
    printf("what is your age?\n");
    printf("\n");

    int age;

    scanf("%d", & age);
    printf("\n");
    printf("your age is %d\n", age);
    printf("\n");

    if (age <= 20) {
      printf("you are yong i like that yoy are my type\n ");
      printf("\n");
    } else if (age > 30) {
      printf("you still yong tho\n ");
      printf("\n");

    }

    printf("Rate your beauty from 10\n");
    printf("\n");
    int beauty;

    scanf("%d", & beauty);
    printf("\n");
    printf("so your beauty is %d\n", beauty);
    printf("\n");

    if (beauty <= 7) {
      printf("you are ugly bitch\n");
      printf("\n");
    } else if (beauty > 7) {
      printf("emmm i see you are so beautiful\n");
      printf("\n");

    }

    printf("would you merry me?\n");
    printf("\n");
    int marry;
    scanf("%d", & marry);
    char yes;
    char no;
    if (marry = yes)

      printf("omg finelly i've got a wife for me\n");

    else if (marry = no)

      printf("it's ok i know that im ugly XD\n");
  }
}

Indentation style - Wikipedia[^]
Best C++ Formatter and Beautifier[^]
Online C/C++ Formatter, Indenter and Beautifier – Techie Delight[^]

Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[^]
ultraedit[^]
Enabling Open Innovation & Collaboration | The Eclipse Foundation[^]
 
Share this answer
 
Comments
CPallini 25-Feb-22 2:23am    
5.
Patrice T 25-Feb-22 5:21am    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900