1

I just wrote a C program to read the name ,age and phone number from the user,store them in variables and display them back.While name and age is working perfectly but its not in case of phone number. if i run the phone number code only it works just perfectly but when done with other 2 it just don't ask for input .

WHOLE PROGRAM CODE

#include<stdio.h>
int main()
{
    int i, age;
    char phone[10];
    char name[100];
    printf("ENTER YOUR NAME:");
    gets(name);
    printf("ENTER YOUR AGE:");
    scanf("%d",&age);
    printf("ENTER YOUR PHONE NUMBER:");
    gets(phone);

    puts(name);
    printf("%d",age);
    puts(phone);


}

WHILE JUST THE PHONE NUMBER CODE WORKS PERFECTLY

    #include<stdio.h>
int main()
{

char phone[10];
    printf("ENTER YOUR PHONE NUMBER:");
    gets(phone);
    puts(phone);
}
melpomene
  • 84,125
  • 8
  • 85
  • 148
RONALDO69
  • 43
  • 2

0 Answers0