C # Tutorial2
C # Tutorial2
4 Find errors if any each of the following looping statements. Assume that all variables
have been declared and assigned values.
a)
count=1;
sum=sum+x;
count=count+1;
Ans:No error
b)
name=0;
do
{
name=name+1;
Console.WriteLine(“India \n”);
}while (name=1);
Ans:while(name==1);
c)
for(x=1;x>10;x=x+1)
{
……….
……….
}
Ans:No error
d)
m=1;
n=0;
for( ,m+n<19;++n)
Console.WriteLine(“Hello\n”);
m=m+10;
Ans:for( ;m+n<19;++n)
Ans:
using system;
class format
{
public static void Main()
{
int i,j;
for(i=1;i<=5;i++)
{
Console.WriteLine(“\t”);
for(j=1;j<=i;j++)
{
Console.Write(“\t”+i);
}
}
}