Skip to main content

All Questions

Tagged with
-2 votes
2 answers
2k views

Read a list of n numbers and make an array in C

So I want to take an input such as this: The first input tells us the size of the array and the second line contains the numbers of array like this: input: 3 1 2 3 And I want to make an array from ...
user avatar
0 votes
1 answer
53 views

The scan function isn't taking values in... It is just displaying the print function

void kmmil() { int x, y; printf("a.KM TO MILS\n"); printf("b.MILS TO KM\n"); char c; scanf("%c", &c); printf("this is the value %c",...
Shaikh Mohammed Ibn Ameen's user avatar
-1 votes
3 answers
1k views

find the sum of 2 numbers in c with input from user

#include<stdio.h> int main(){ int num1=0; int num2=0; int sum=0; printf("enter 2 numbers\n"); scanf("%d %d",&num1,&num2); sum=num1+num2; printf("%d",&...
Rishi Gandhi's user avatar
0 votes
1 answer
1k views

ARM assembly: How do I change the code to ask number input then print it out and then ask character input and print it out?

@ Use these commands to assemble, link, run and debug this program: @ as -o student_inputC.o student_inputC.s @ gcc -o student_inputC student_inputC.o @ ./...
MaciG's user avatar
  • 21
0 votes
1 answer
721 views

scanf each digit of integer AND store the whole number in C

Example input: 12345 As you can see I can store each digit "1" "2" "3" "4" "5" through scanf but how do I store the whole number "12345"? Can it happen within the same scanf line? #include <...
William Toscano's user avatar
0 votes
2 answers
77 views

how scanf handles standard input vs pipelined input

In the following code: #include <cstdio> using namespace std; int N; char x[110]; int main() { scanf("%d\n", &N); while (N--) { scanf("0.%[0-9]...\n", x); printf("...
coder27's user avatar
-1 votes
3 answers
547 views

C power function and scanf [closed]

So basically, I need to get an input and square it. some reason the pow() function isn't working. #include <stdio.h> #include <math.h> int main (){ int in, ans; scans("%d", &in);...
ewfwef.yyyy's user avatar
2 votes
2 answers
608 views

"Freezing" an input line in console and printing on the lines above it?

I was wondering if there was a way to "freeze" an input line in order to separate input and output from each other in c. For instance, my console output is currently something like this: 1 ...
Colin Fausnaught's user avatar
-1 votes
2 answers
58 views

Trying to print smallest, biggest and the mean value. Smallest isn't being printed correctly

So, I'm trying to create a program that outputs the smallest input, the biggest input, and the mean or average of the inputs. So far, the biggest and the average are working, but unless I enter ...
Shimzay's user avatar
3 votes
5 answers
115 views

if statement for string comparison is not executing properly

I am trying to write a simple program for finding out areas of different shapes.The program is compiled fine but when it runs it does not give me the right answer. I mean When it runs it asks: ...
gurpinder singh's user avatar
0 votes
1 answer
48 views

How to fix the running of my program in terms of conditional statements and output in C?

I have a problem with my input for my program: #include <stdio.h> #include <stdlib.h> int confirm() { char c; printf("Confirm (y/n): "); scanf("%c", &c); while (...
George Cavalevu's user avatar
-1 votes
1 answer
74 views

Can't separate columns when reading txt file

Hi I managed to read txt files and printing them on the console window. I was given a task to select and sample a certain amount of data. Example of txt file: Voltage (V),Current (I),Power (W) 50,2,...
Bonavia's user avatar
  • 75
4 votes
2 answers
5k views

Wrong format specifiers in scanf (or) printf

As of the printf function is concerned, I understand the following from few references and experiments. When we try to print an integer value with format specifiers that are used for float (or) double ...
Vivek Maran's user avatar
  • 2,783
1 vote
2 answers
277 views

C Prints One Char More Without Value

I am trying to print the ASCII values of 3 char-type characters. When I input the first char it doesn't print the value of the char. After the first char it starts to give the value. #include <...
Ahmet's user avatar
  • 11
1 vote
6 answers
3k views

C Programming Input Error

int main(void) { char *input; printf("prompt>"); scanf("%s", input); printf("%s", input); return 0; } prompt>input RUN FAILED (exit value 138, total time: 3s) What's wrong ...
Spencer's user avatar
  • 4,168