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

  • SEARCH
  • Home
  • 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 8750435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:51:47+00:00 2026-06-13T12:51:47+00:00

I am absolutely brand new at programming and im not sure how to explain

  • 0

I am absolutely brand new at programming and im not sure how to explain what im doing here.

The whole purpose of this piece is to enter values and then print them out in the same order. Now I wanna quit from entering values when pressing ‘q’ and so I have to scanf for chars but when I assign them back to the int array the values are not the same.

Hope that makes any sense to you but in any case heres my code:

#include <stdio.h>
#include <stdlib.h>
#define SIZE  5000
define flush fflush(stdin)

main() {
    int input[SIZE] = {0},i = 0;
    int counter = 0;
    char inputs, quit;

     do {
        system("cls");
        printf("Input number ('q' to quit and display numbers entered): ");

        flush;
        scanf("%c",&inputs);
        flush;

        if (inputs == 'q')
            quit = 'q';
        else {
            input[i] = inputs;
            counter++;
            i++;
        }
    } while (i < SIZE && quit != 'q');

    for(i = 0; i < counter; i++){
        printf("%i.%i\n", i + 1, input[i]);
    }

    system("pause");
}

Ive been trying to do this on my own btw and also researched some information online regarding chars but couldnt find anything that would help me. Thanks a lot in advance.

  • 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-13T12:51:48+00:00Added an answer on June 13, 2026 at 12:51 pm

    You should nor be getting integer through %c neither assign char values to integers variables when that is not the intention, rather you should approach something like this

    i = 0;
    do {
      printf("Enter a number: ");
      scanf("%d", &input[i]);
      i++; counter++;
      printf("Do you want to continue? (y/n) : ");
      scanf("%c", &inputs);
    } while(inputs == 'y');
    

    or u can get the number of integer inputs upfront and loop to get that much integers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm an absolutely newbie to both this site and programming so please be patient
I am brand new to both java and to maven, so this is likely
this is absolutely driving me crazy! Can someone please explain why this code isn't
I'm brand new to this and I'm trying build a simple layout of divs.
I am absolutely new in Servlet technology and this is absolutely basic question, but
Firstly apologies if this is a really simple question but Git is absolutely brand
This is driving me absolutely bonkers, and it seems like such a simple thing
I am absolutely and totally new to rails, so the answer is probably very
This is driving me absolutely insane. I know that, to change the formatting of
Here's the error: The incoming request does not match any route. Basically I upgraded

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.