+ 2
What is wrong with my code?
https://code.sololearn.com/caXSRS4qOPaX/?ref=app It should look like this... Enter initials: SCO Enter age: 19 Output... Hi! S.C.O., your age next year would be 20.
3 Answers
0
Your first mistake in first scanf line 10 you using multiple format specifiers and with string input & is optional you dont need to write address here . Same in line 17 you have written 3times %s just remove them u need only one specifier
See this one
#include <stdio.h>
#include <stdlib.h>
int main()
{
int age,ageNY;
char name[10];
printf("\nEnter initials: ");
scanf("%s",name);
printf("\nEntered initials:%s ",name);
printf("\nEnter age: ");
scanf("%d",&age);
printf("\nEntered age: %d",age);
ageNY = age + 1;
printf("\nHi %s, your age next year will be %d.",name,ageNY);
return 0;
}
- 2
I'm not so good in C but I think this should fix it.
scanf("\n%s",&*name);
printf("\nHi! %s, your age next year will be %d.",name,ageNY);