Computer Science, asked by dhakka1804, 1 year ago

C program to print your details

Answers

Answered by muvvadhanush007
0
when you use scanf, %c is intended to get a single character. If you want to get a string, you need to use %s.

Also, in C langage, string are just char arrays. So you need to declare a char array.

#include <stdio.h> int main () { char yourname[100]; int yourage; printf("Whats your name?\t"); scanf("%s",yourname); //i let you read the doc to avoid overflow :) printf("How old are you?\t"); scanf("%d",&yourage); printf("You are %d years old and your name is %s \n\n\n",yourage,yourname); system("pause"); return(0); }
Similar questions