answersLogoWhite

0


Best Answer

This is a very wide question, which could have many different answers, from the simple to the complex.

However, as a start, an example of a program in C where you enter distance and time and calculate speed might look something like this:

(PLEASE NOTE: I CAN'T GET THIS TO FORMAT PROPERLY - THERE SHOULD BE A BLANK LINE AFTER "stdio.h" and after each semi-colon)

#include "stdio.h"

int main(void) {float distance, speed, timetaken;

printf("Enter distance in miles:");

scanf("%f", &distance);

printf("Enter time taken in seconds:");

scanf("%f", &timetaken);

speed = distance / timetaken;

printf ("\nSpeed = %10.2f (miles per second)\n", speed);

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C programming example source code
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Movies & Television

Least common multiple in C programming?

The following code for example is a solution (you could do it with less variables, but this is more readable):int GCD(int a, int b){int n, k, c;n = (a>b)?a:b;k = (a>b)?b:a;while (k){c = n%k;n=k;k=c;}return n;}


Is CPP a high level language?

C++ (CPP) is a computer programming language developed by Bjarne Stroustrup in the early 1980s. C++ is an extended version of the C programming language for systems programming and high-performance applications. C++ is often called a high-level language, but what does that mean? In general, computer programming languages can be divided into two categories: low-level languages and high-level languages. Low-level languages, such as assembly language, are very close to a computer's machine code to execute instructions. These languages give programmers much control over the hardware but are also very difficult to learn and use. On the other hand, high-level languages are designed to be more user-friendly and easier to learn. They abstract away some of the hardware details and provide more robust and expressive constructs for writing programs. High-level languages often use more English-like syntax and are easier to read and write. C++ is considered a high-level language because it provides a wide range of programming constructs that abstract away some of the hardware details. These constructs include objects, classes, templates, and exceptions. C++ also includes memory management features, making it easier for programmers to allocate and deallocate memory without worrying about the underlying hardware. Another reason why CPP is considered a high-level language is its extensive use of libraries. It has many standard libraries that provide solutions for everyday programming tasks, such as string manipulation, file I/O, and network programming. These libraries abstract away the hardware details and provide a higher-level interface for programmers. Despite being a high-level language, C++ still provides low-level features that allow programmers to write code that can interact directly with the hardware. For example, CPP provides a way to write inline assembly code, which can perform low-level operations impossible with high-level constructs. Here are dome features of CPP: Object-oriented programming: C++ supports object-oriented programming, which means you can organize your code into reusable modules that can be easily modified and extended. Platform independence: C++ code can be compiled and run on a vast variety of platforms, including Windows, macOS, Linux, and mobile devices. Memory management: C++ gives you direct control over memory allocation and deallocation, which can help optimize the performance of your applications. High performance: C++ is a compiled language, which means that it can be optimized for high performance. It also has a number of low-level features that allow you to write efficient code. Compatibility with C: C++ is mainly compatible with C, which means that you can easily incorporate existing C code into your C++ projects. To sum up, C++ is considered a high-level language because it provides powerful and expressive programming constructs that abstract away some of the hardware details. C++ also provides extensive libraries that make it easier for programmers to write code without worrying about the underlying hardware. Despite being a high-level language, C++ still provides low-level features that allow programmers to interact directly with the hardware when necessary.


What are the similarity between c and c plus plus compiler?

When Bjarne Stroustrup developed the first version of C++ in 1979 (which was originally called 'C with Classes'), his custom-built compiler did nothing more than convert his C++ source code into C-compliant code which could then subsequently be compiled by the standard C compiler to produce the required object files. Nowadays, the C++ compiler handles everything itself, but does more or less the same job, with the addition of specialised optimisation routines to produce object files efficiently, without the need to convert to an intermediate C source.


Are the same programming languages that used to create computer software also used in video game systems such as Xbox and PS3?

Yes. Games for consoles are written, like PC programs, in languages such as C. To enable these games to run on consoles, instead of PCs, a few changes are made, however. Different code libraries are used, so code for drawing onscreen or grabbing input will differ. A different compiler, designed for the console, is used to compile the program into machine code. In general, though, the C code for a PC game is much like the C code for its console counterpart. Assuming that it's written in C, obviously.


What does c stand for in C language?

It doesn't stand for anything. The 'C' language was developed as an improvement over its predecessor, which was called 'B'. (I'm not joking). The predecessor of 'B' was called 'BCPL', which was an initialism for "Basic Combined Programming Language". The ancestor of BCPL was CPL, and CPL was a descendant of ALGOL.

Related questions

Getting source code of c?

C is a programming language, so it doesn't have source code.(On the other hand, C compilers do have source code, but you, as a beginner in programming, could not understand them.)


Microsoft office's source code written by which programming language?

C++


C programming source code for push down automata?

i cant sorry


What translator is needed for C programming language?

To translate the C source code program, you need a program called a "C compiler".


How Create mouse in C programming source code?

Here is the article for Mouse programming in C. In this link full details are given nicely.http://electrofriends.com/articles/computer-science/c-tutorials/mouse-programming-in-cc/


Code for creating pascal's triangle in C programming language?

code for creating pascal's triangle in C programming language?


What is a C compiler as used in C programming?

In C programming, C compiler is user to translate C source into C object module.


Can you do c plus plus programming on a mac?

You may use one of several open source compilers and code editors (or even IDEs) to develop and compile C++ code that will operate on a Mac.


What is the use of c compiler in windows?

The c compiler in Windows converts the binary code from source files. C is a compiled programming language and it needs to be converted for the program to run.


What is source code c?

"Source code", in a programming language, refers to the original program, as written by a programmer (and more or less readable by humans); the version of the program before it is converted into machine language by the compiler.


What is programing in c?

C++ is a programming language which gives the user the chance to create working applications through creating source code.


Example of a programming language?

C, C++, Java, C-Sharp