Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Select error in the given program?

  1. Static Void Main(String[] args)
  2. {
  3. const int m = ;
  4. int n = ;
  5. const int k = n / 5 * * n ;
  6. Console.WriteLine(m * k);
  7. Console.ReadLine();
  8. }

a) ‘k’ should not be declared constantb) Expression assigned to ‘k’ should be constant in naturec) Expression (m * k) is invalidd) ‘m ‘ is declared in invalid format

user-image
Question added by Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
Date Posted: 2016/10/20
Sayed Elshayeb
by Sayed Elshayeb , senior analyst programmer , EPL House

m,n definition is invalid

definition of k has 2 problems:

  1. you can't assign a variable to const
  2. the double * means that n is a pointer, if you need the power use the "Math" class

Awwab Ahmed
by Awwab Ahmed , Web-Developer, Graphic-Designer. , Conobio

b) Expression assigned to ‘k’ should be constant in nature

Mohammad Nadir Roshan
by Mohammad Nadir Roshan , Technical Support Specialist , FreeBalance Co

There are 3 major errors:

1.Two invalid expression term ';' which are for "m=;" and "n=;" as they need to be initialized (given a value).

2. The * or -> operator must be applied to a pointer: which in the line 5 (const int k = n / 5 * * n ;)

     a. operator is invalid for "5**n)

     b. And we have never declared a pointer to use a "*n" also.

3.The expression being assigned to 'k' must be constant: meaning that constant values should be constant and there is no way you could assign a variable to a constant.

Mohannad Bakbouk
by Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb

There are Error in code 

i'm sorry for that 

  1. const int m =1 ;
  2. int n =5;

Shahid Salam Khan
by Shahid Salam Khan , Software Engineer , Xavient Information Systems

Everything is wrong except Console.WriteLine and readline

Pathan Zarrar Khadar Khan
by Pathan Zarrar Khadar Khan , Windows System Administrator , Dyce Tech Pvt Ltd

const int m = ;  Invalid Declaration 

 

Hassan Elsherbiny
by Hassan Elsherbiny , .Net Developer , Tidal4Information Systems

const int m = '//This Should has a value

int n = ;//This Should has a value

const int k = n / 5 * * n ; //** Is Not valid operator

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.