What is wrong with my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

11th Oct 2021, 2:24 AM
Leoror
Leoror - avatar
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; }
11th Oct 2021, 3:51 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
- 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);
11th Oct 2021, 2:42 AM
Stefanoo
Stefanoo - avatar