Click here to Skip to main content
15,892,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Everyone!

Q 1:Please Help Me i am Trying to make Quiz Program in C# . but i get a little problem when i used Consol.clear() then all data will be delete but i want to delete Specific Area. Because when all Console Clear Then Score Value Automatically Reset To (0).and i did not want this .

i want in the Next Question Score Value Automatically Increase or Decrease According to The Given Condition.on The Same Give Position.

Q 2:When user Enter The Answer Of Question one Then Cursor Position Remain On The Top But i want that it Automatically Come On The Same Place Like Question One.

Please Help me If Any one know about this

code

C#
 int x;
Console.SetCursorPosition(57, 2);
Console.Write("Score:");
Console.Write("\n\nQ:Pakistan National Gmae Is....?");
Console.Write("\n\n1:Cricket.\n\n2:Hockey.\n\n3:Basketball.\n\n4:None.");
Console.Write("\n\nChoice:");
x = Convert.ToInt16(Console.ReadLine());
if (x == 1)
{
    Console.SetCursorPosition(65, 2);
    Console.WriteLine("{0}", total+1);
}
else if (x!= 1)
{
  Console.WriteLine("{0}",total--);
}
 console.clear();
Console.Write("\n\nQ:Australia National Gmae Is....?");
Console.Write("\n\n1:Cricket.\n\n2:Hockey.\n\n3:Basketball.\n\n4:None.");
Console.Write("\n\nChoice:");
if (x == 1)
{
    Console.SetCursorPosition(65, 2);
    total = total + 2;
    Console.WriteLine("{0}", total);
}
else if (x != 1)
{
    Console.WriteLine("{0}", total--);
}
Console.ReadLine();
Posted
Comments
MT_ 20-Aug-14 16:50pm    
curious, why are you trying to make it a console application? Why not windows form application?
Sergey Alexandrovich Kryukov 20-Aug-14 16:53pm    
Agree. Writing console applications is someone's "National Gmae". :-)
No, I'm not against console applications, I'm against writing a console quiz, and, frankly, any quiz at all...
—SA

What's wrong with reading original MSDN documentation? http://msdn.microsoft.com/en-us/library/system.console.clear%28v=vs.110%29.aspx[^].

I think, writing such application is one of the worst ideas of the application, anyway.

—SA
 
Share this answer
 
I hopefully believe, you are writing this program for academic interest :-)

Your code has many issues...some are sorted below. Check if this helps. write some more code, experiment some more and read some more. Then if you still have issues, come back

C#
int x;
 int total = 0;
 Console.SetCursorPosition(57, 2);
 Console.Write("Score:");
 Console.Write("\n\nQ:Pakistan National Gmae Is....?");
 Console.Write("\n\n1:Cricket.\n\n2:Hockey.\n\n3:Basketball.\n\n4:None.");
 Console.Write("\n\nChoice:");
 x = Convert.ToInt16(Console.ReadLine());
 if (x == 1)
 {
     Console.SetCursorPosition(65, 2);
     Console.WriteLine("{0}", total + 1);
 }
 else if (x != 1)
 {
     Console.WriteLine("{0}", total--);
 }
 Console.SetCursorPosition(1, 2);

 Console.Write("\n\nQ:Australia National Gmae Is....?");
 Console.Write("\n\n1:Cricket.\n\n2:Hockey.\n\n3:Basketball.\n\n4:None.");
 Console.Write("\n\nChoice:  ");
 Console.CursorLeft = Console.CursorLeft - 2;
 x = Convert.ToInt16(Console.ReadLine());
 if (x == 1)
 {
     Console.SetCursorPosition(65, 2);
     total = total + 2;
     Console.WriteLine("{0}", total);
 }
 else if (x != 1)
 {
     Console.SetCursorPosition(65, 2);
     Console.WriteLine("{0}", total--);
 }
 Console.ReadLine();


Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900