LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-10-2004, 07:20 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question simple c program


How about a simple c program?

Last edited by liguorir; 05-29-2004 at 09:30 AM.
 
Old 05-10-2004, 07:45 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
This is c++, but does more or less what you want, I think? :S

Code:
#include<iostream>
using namespace std;


/* this function takes two arguments
   and returns the sum of them plus
   prints a message to the screen */
void calculate(int a, int b) {
	int total = a + b;
	cout << "total sum is of number 1 + number 2 is: ";
	cout << total;
}

int main() {
    // Variables
    int someInt;
    int someInt2;

    cout << "Insert number 1\n";
    cin >> someInt;
    cout << "Insert number 2\n";
    cin >> someInt2;

    // call the method calculate
    // and pass number 1 and 2 as
    // aguments.
    calculate(someInt, someInt2);

    return 0;
}
 
Old 05-10-2004, 07:50 PM   #3
nodger
Member
 
Registered: Oct 2003
Location: Ireland
Distribution: Slackware 9.1, Ubuntu
Posts: 192

Rep: Reputation: 30
thats a c++ program, Megaman
 
Old 05-10-2004, 08:04 PM   #4
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
I know . It has been a while since I used C. I think it's too primitive... lol, now peoples will flame me

Code:
#include<stdio.h>


/* this function takes two arguments
   and returns the sum of them plus
   prints a message to the screen */
void calculate(int a, int b) {
	int total = a + b;
	printf("%s", "total sum is of number 1 + number 2 is: ");
	printf("%d", total);
}

int main() {
    // Variables
    int someInt;
    int someInt2;

    printf("%s", "Insert number 1\n");
    scanf("%d", someInt);
    printf("%s", "Insert number 2\n");
    scanf("%d", someInt2);

    // call the method calculate
    // and pass number 1 and 2 as
    // aguments.
    calculate(someInt, someInt2);

    return 0;
}
 
Old 05-29-2004, 06:22 AM   #5
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
what the... the guy simply deleted his post
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple program help! rohitkara Linux - General 1 05-24-2005 08:57 PM
simple C program problem mined Programming 2 05-08-2004 05:42 AM
Compiling a simple C++ program kbeaver Programming 27 02-06-2004 08:02 PM
simple program bprasanth_20 Programming 5 10-29-2003 12:55 AM
Help with the following simple C program ..... purpleburple Programming 5 09-13-2002 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration