Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8242221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:05:39+00:00 2026-06-07T21:05:39+00:00

I was participating in some coding contests and luckily my code also ran. However

  • 0

I was participating in some coding contests and luckily my code also ran. However my solution was not expected because i was wrong with the pattern of taking input.


The question involved taking in an integer as an input and performing some operation and returning a different or same integer. I do not have any problem with the program, I just don’t know how to code so as to take inputs like this


Input

The input will contain several test cases (not more than 10). 
Each test case is a single  line with a number n, 0 <= n <= 1 000 000 000. 
It is the number given as input.

Output

For each test case output a single line, containing the integer returned.

Example

Input:
12
2

Output:
13
2

My code is


#include <stdio.h>

int functionReturningInteger(int n)
{
// implementation
........ 
return num;
}


int main(void)
{

int number;
//printf("Enter the number: ");
scanf("%d",&number);
printf(functionReturningInteger(number));
return 0;

}


How am i supposed to know how many inputs they will give ( although they do provide a maximum limit). And if i use an array to store these inputs whose size is equal to the maximum limit, how do i check the size of an integer array in c ?


I will appreciate anybody helping out with a small piece of code. Also if am able to test it against an input test file and generate an “output.txt” (output file). I already have the desired output file “des.txt”. Then how can i match whether both the files are same or not ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:05:40+00:00Added an answer on June 7, 2026 at 9:05 pm
    #include <stdio.h>
    int scanned;
    while((scanned = scanf("%d", &number)) != EOF) {
        printf("%d\n", functionReturningInteger(number));
    }
    

    If scanf detects the end of input before a successful conversion, it returns EOF.

    For the other questions, redirect input and output,

    $ ./your_prog < input.txt > output.txt
    

    and compare

    $ comp output.txt des.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am participating in some programming competitions, and on many problems there's the need
I am participating in the development of a distributed solution, based on RMI, and
A research group I'm participating in currently hosts all of their code in a
For what purposes would you want to obfuscate your code? I have not run
I'm participating in google code jam. Before anything I want to say that I
I can figure out why this simple code would not compile. May be fresh
I'm participating in a computer security competition this weekend and I'm trying to make
i am participating in google codejam 2012. I have red their Quick start guide
I'm really interested in participating as a new developer in an OpenSource project. My
How can I get all types participating in a linq expression? I actually need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.