TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
327.8k
Unassigned local variable
Dec 24 2011 4:46 PM
Though 'p' is declared in the Main() method why program is producing error message.
Error1
Use of unassigned local variable 'p'
using System;
namespace _6e9
{
class Program
{
static void Main(string[] args)
{
double sum = 0, p;
int x;
double[] price = new double[5];
for (x = 0; x < price.Length; ++x)
{
Console.Write("Price of item #{0} $", x + 1);
p = Convert.ToDouble(Console.ReadLine());
sum = sum + p;
}
for (x = 0; x < price.Length; ++x)
{
if (p < 5)
{
Console.WriteLine("${0} is less than $5", p);
Console.WriteLine();
}
}
Console.ReadKey();
}
}
}
Reply
Answers (
3
)
Check if email address really exsist or not using c#
Calling A Console App From A Form App And Some Little Questions