I guess the path for hadoop and java is not set properly in your windows system. Follow the below steps:
1. Go to Control Panel\System and Security\System , click on environment variables and create user variable for Hadoop and system variable for Java as mentioned below, if its not set:
Variable name: HADOOP_HOME
Variable value: E:\hadoop-2.7.1
Note: my hadoop is present in E drive
Variable name: JAVA_HOME
Variable value: C:\Program Files\jdk1.8.0_51
2. Add bin directories of java and hadoop in 'Path' variable name present in system variable:
Once this is set, your hdfs or hadoop command will work.
Open a new command prompt, type hdfs and click on enter. If you get all hdfs command options, its means path got set correctly and now you can run the format command. But if you don't get hdfs command options, the path was not set correctly, check it again.
Hope this helps!!