0
I have this code here that is not reading the characters correctly when printing the data filled by the user on the screen. Can you help me??
//Question 1) Make an algorithm that reads a user’s name, id, age, gender, address, phone number, and mobile phone. //Print user data on screen. (Value 0.1 point)
#include <stdio.h>
#include <stdlib.h>
main(){
char nome [50], sexo [50], end [50];
int rg, idade, telefone, celular;
printf("Nome: "); scanf("%s",nome);
printf("RG: "); scanf("%d",&rg);
printf("Idade: "); scanf("%d",&idade);
printf("Sexo: "); scanf("%s",sexo);
printf("Telefone: "); scanf("%d",&telefone);
printf("Celular: "); scanf("%d",&celular);
printf("Endereco: "); scanf("%s",end);
printf("\nNome:%s",nome);
printf("\nRG:%d",&rg);
printf("\nIdade:%d",&idade);
printf("\nsexo:%s",sexo);
printf("\nTelefone:%s",&telefone);
printf("\nCelular:%d",&celular);
printf("\nEndereco:%s",end);
This code is language
C
, and notC#
.– Pedro Gaspar
You use the pattern
&variável
in functionscanf
, because it needs to change the value of the variable, but in the functionprintf
you use onlyvariavel
, and not&variavel
.– Pedro Gaspar