473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

sum in command line argument

1
Expand|Select|Wrap|Line Numbers
  1. class N2
  2. {
  3.   public static void main(String[] args){
  4.  
  5.       int a,b,c;
  6.  
  7.       int  sum=0;
  8.  
  9.       for(int i=0;i<=args.length;i++)
  10.       {      
  11.           {
  12.  
  13.               sum+=i;
  14.  
  15.           }
  16.  
  17.           System.out.println(sum);
  18.      }
  19.  
  20. }
  21. }
Nov 29 '19 #1
3 4459
gits
5,390 Expert Mod 4TB
do you have a question regarding the code you posted?
Nov 29 '19 #2
Ishan Shah
47 32bit
First of all, You have to post the question regarding the code
But as per your code, I think you want to sum the a,b, and c variable in which value comes from the command line argument
So you should run the code by the following command in which the parameters are passed at run time

javac N2.java
java N2 4 5 6
Oct 2 '20 #3
dev7060
633 Expert 512MB
First, OP didn't even use the declared vars. Second, the program won't work unless the values are parsed as int. Third, the output statement to print the sum is in the wrong block.
Oct 2 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
2
by: Eric Kimball via AccessMonster.com | last post by:
I have created an MDE file but I need it to run spacific updates at a certain time. I want windows schedule to run the mde at midnight with a command line argument to activate those functions. Can...
1
by: DanielB | last post by:
Does anyone know what the command line argumentto launch a screensaver's options/configuration dialog is on Windows XP Pro? From most of the example source code I can find on the web, it would...
1
by: Vagabond Software | last post by:
I am launching the EXTRACT.EXE command from my application using the Process class. Everything seems to be working fine except the path I use as the destination argument for the EXTRACT command...
1
by: evantri | last post by:
i tried to develop a program to include command line argument. if there is nothing than a.out (i use cc compiler), i want to finish the program. but i can't exit from the program. someone help me...
3
by: jlw16 | last post by:
Hello, I’m trying to use my vbs script to get a command line argument for a file which will need to be opened through QuickTestPro. Below are the commands I’m using: Dim qt_file 'As String ->...
6
by: virgincita schmidtmann | last post by:
Good evening, I would like to pass the size of an array from the commandline. int main(int argc, int *argv) { .... max=*argv; int list; ....
2
by: uday | last post by:
Hi Friends, My shell is giving me the following error for "gprof" comand. gprof : file 'xxx.par' does not appear to be in gmon.out format where xxx.par is the parameter file which i am using...
6
by: =?Utf-8?B?Rm9ycmVzdCBIZWxsZXI=?= | last post by:
The only code that is helpful is this: fp = New IO.StreamReader(filename, New System.Text.UnicodeEncoding(True, False), False) If I pass a command line argument to my program that is not from...
0
by: visweswaran2830 | last post by:
Hi, I want to create an installer using NSIS, In which, that installer should accept command line arguments. for eg: Let us consider, I have an installer, It contains two exe's, If I run that...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.