My very first program, is not working :-/? [C]

Lumia925

Estimable
Oct 16, 2014
68
0
4,590
This is the first time I typed a program on my laptop, and it's not working as expected.
Here's what it looks like:
source.png

And here's a trial run:
output.png


What exactly am I doing wrong? Thanks for your help..

Okay, the source code is too minuscule to read, here's a copy/paste of the source code..

C++:
#include<stdio.h>
int main()
{
	char name[20];
	int item=0;
	float cost=0;
	printf("Enter item name, followed by return \n");
	scanf( "%[^\n]", name); //[^\n] forces scanf to accept ALL input until ENTER is pressed
	printf("Enter item number, followed by return (no space allowed) \n");
	scanf( "%d", &item);
	printf("Enter cost, followed by return (decimal values allowed) \n");
	scanf( "%f", &cost);
	printf("Here's what's stored in the computer's RAM \n");
	printf("Item name = %s \n", name);
	printf("Item number = %d \n"), item;
	printf("Item cost =%f \n"), cost;
	getch();
	return 0;
}
 

Lumia925

Estimable
Oct 16, 2014
68
0
4,590


didn't understand... the last printf looks fine to me, where is the error? can you write the correct printf please?
 

Lumia925

Estimable
Oct 16, 2014
68
0
4,590


Okay gotcha, damn, such a silly error :p
Here's what the correct code should look like:
C++:
#include<stdio.h>
int main()
{
	char name[20];
	int item=0;
	float cost=0;
	printf("Enter item name, followed by return \n");
	scanf( "%[^\n]", name); //[^\n] forces scanf to accept ALL input until ENTER is pressed
	printf("Enter item number, followed by return (no space allowed) \n");
	scanf("%d", &item);
	printf("Enter cost, followed by return (decimal values allowed) \n");
	scanf("%f", &cost);
	printf("Here's what's stored in the computer's RAM \n");
	printf("Item name = %s \n", name);
	printf("Item number = %d \n", item);
	printf("Item cost =%f \n", cost);
	getch();
	return 0;
}

Thank you so much for you help bro :)
 

TRENDING THREADS