Asked inCognizant,GenC

Spot the error in the following 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
2y

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
3y
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!
Select
Add answer anonymously...

Cognizant GenC interview questions & answers

A GenC was asked 1w agoQ. How willing are you to adapt to new technologies?
A GenC was asked 2w agoQ. What is the difference between delete and truncate?
A GenC was asked 2w agoQ. What is the self keyword in Python?

Popular interview questions of GenC

A GenC was asked 1w agoQ1. How willing are you to adapt to new technologies?
A GenC was asked 2w agoQ2. What is the self keyword in Python?
A GenC was asked 2w agoQ3. Explain the concepts of OOP.

Top HR questions asked in Cognizant GenC

A GenC was asked 5mo agoQ1. Can you tell me about yourself?
A GenC was asked 6mo agoQ2. Can you explain your project in detail?
A GenC was asked 7mo agoQ3. Tell me about your projects.
Cognizant GenC Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits