Plz help super noob (run-time check failure #3 variable is being used without being initialized

Can anybody plz help, very new to programing,trying to make program to display largest of a number of inputs.Code i have is

/*Program showing largest number of ten inputs
written by ish*/

#include<stdio.h>
#include<conio.h>

void main()
{
int num1,num2,num3;
char largest;
largest=num1;

printf("\n\nplz enter number ");
scanf("%d",&num1);
if(num1>0)
num1=largest;
printf("\nplz enter next number ");
scanf("%d",&num2);
if(num2>largest)
num2=largest;

printf("\nanother number ");
scanf("%d",&num3);

if(num3>largest)
num3=largest;
printf("\n%c is the largest",largest);
getch();
}
totally lost sorry for the simplicity of my problem
plz help
Your initialisation error is because you're assigning 'largest' the value of num1, and num1, at that point, hasn't been given a value (is not initialised). To fix the error you could assign num1 a value before using it, but what you really want to do (for this example) is set largest to zero.

Also, where you track which of num1, 2 or 3 is the largest, you need to set largest = num1/2/3, not num1/2/3 = largest, and your format specifier in the final printf needs to be %d (outputs an int), not %c (outputs a character).

Cheers
Jim
thankyou so much for your speedy reply
Topic archived. No new replies allowed.