Asked inCognizant,GenC

Code debugging question:- We have to spot the error in the code and rewrite it. #include int main() { int num, LD; printf("Enter a number" 4589); scanf("%d", &num); LD = num/10; printf(" \n The Last Digit of a Given Number %d = %d", num, LD); return 0; }

AnswerBot
1y

Code has a syntax error in printf statement. It should have a placeholder for user input.

  • Add a placeholder in printf statement for user input.

  • Use %d instead of 4589 in printf statement.

PrepInsta
author
2y
Solution: #include int main() { int num, LD; printf("Enter a number" 4589); scanf("%d", &num); LD = num%10; printf(" \n The Last Digit of a Given Number %d = %d", num, LD); return 0; }
Help your peers!
Add answer anonymously...
Cognizant GenC Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter