LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-28-2015, 11:01 PM   #1
varun r
LQ Newbie
 
Registered: Dec 2015
Posts: 1

Rep: Reputation: Disabled
Kernel Development Programming


how do i add or subtract or Multiply or divide two float variables in Linux kernel Program .
//
float a,b,c;
c=a+b;
c=a-b;
c=a*b;
//
and trying to use insmod this shows error and unknown symbol.
can u help me out .
Thankyou
Email-id:varunr047@gmail.com/varunr047@yahoo.com
 
Old 12-29-2015, 07:31 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
DO NOT POST EMAIL ADDRESSES

That code all works. However what you've included there is not a complete C program.

You should assign values to the variables a and b so that you don't just have random values. Further, you should print out the value of c each time.

The insmod command makes zero sense. There is no module to insert. EDIT: Sorry you did say "kernel programming". Well then you've apparently written a module. Please post the entire module and describe what you've done to compile it.

You write a C program, compile it using something like gcc(1) and then you run it from your terminal/command prompt.

So let's start with the beginning. Please use [code][/code] tags around your code, there are instructions in the LQ FAQ as well as a link in my signature.

Post all of what you have for code.

Or is all you have what you typed in?
Quote:
Originally Posted by varun r View Post
float a,b,c;
c=a+b;
c=a-b;
c=a*b;
If so, then you haven't written a complete C program, such as the classic example:
Code:
// Sample file: hello.c

#include <stdio.h>

void main(void)
{
    printf("Hello World!\n");
}
And you compile that using GCC:
Code:
$ gcc -o hello hello.c
And then you run it from the command line:
Code:
$ ./hello
Hello World!
$
Extend that example to put your math code in the program as opposed to just printing Hello World! and also print out the value of c after each computation. Suggest you look up how to use printf() formatting to output a float value.

My personal suggestion moving to a future step is to consider double over float. Just my personal take, float variables do work here.

Last edited by rtmistler; 12-29-2015 at 07:33 AM.
 
1 members found this post helpful.
  


Reply



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
programming tools to aid C development irfanhab Programming 2 06-03-2006 10:07 AM

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

All times are GMT -5. The time now is 12:49 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