Results 1 to 4 of 4

Thread: What is the shell program to calculate addition of two numbers?

  1. #1
    Join Date
    Nov 2009
    Posts
    95

    What is the shell program to calculate addition of two numbers?

    Hi,

    I am learning the shell programming. I am aware about the c programming , but shell programming seems different than it. I need your help to code the shell program which will calculate the addition of the given two numbers. Another similar shell program will also work for me.
    I would greatly appreciate your help.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: What is the shell program to calculate addition of two numbers?

    Hi,

    The programming logic behind the Shell programming and C programming is not is same, only there is difference in syntax. Below is the shell program which displays the addition of two numbers:
    #!/bin/Bash

    echo "Provide two numbers for addition:"

    read a
    read b

    answer=$(($a+$b))

    fi

    echo $answer

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: What is the shell program to calculate addition of two numbers?

    Hi friend,

    Please study carefully below shell program for addition:
    #! /bin/sh

    echo "Enter 1st number ="

    read p

    echo "Enter 2nd number="

    read q

    m="exp $p +$q"

    echo "addition is =$m"

  4. #4
    Join Date
    Nov 2009
    Posts
    95

    Re: What is the shell program to calculate addition of two numbers?

    I have tried above shell program and it's executed successfully on my system. At the first time of execution of the above program I got some syntax error, But I solved that. I have also checked the output of the program and it was also correct.
    Thanks to all.

Similar Threads

  1. How to calculate told of numbers combination in Microsoft Excel list
    By Ankit Zh@very in forum MS Office Support
    Replies: 3
    Last Post: 24-01-2012, 02:23 PM
  2. Replies: 1
    Last Post: 20-11-2010, 07:07 PM
  3. Program : How to calculate the median in C++?
    By UseME in forum Software Development
    Replies: 3
    Last Post: 19-01-2010, 12:08 PM
  4. Need C program code to count numbers of negative & positive numbers
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 02:00 PM
  5. java script code for addition of two numbers
    By Sonam Goenka in forum Software Development
    Replies: 6
    Last Post: 05-01-2010, 10:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,693,610.12283 seconds with 16 queries