C (, as in the letter c) is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions. It has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computer architectures that range from supercomputers to PLCs and embedded systems.
A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix. It was applied to re-implementing the kernel of the Unix operating system. During the 1980s, C gradually gained popularity. It has become one of the most widely used programming languages, with C compilers from various vendors available for the majority of existing computer architectures and operating systems. C has been standardized by the ANSI since 1989 (ANSI C) and by the International Organization for Standardization (ISO).
C is an imperative procedural language. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant C program written with portability in mind can be compiled for a wide variety of computer platforms and operating systems with few changes to its source code.As of January 2021, C was ranked first in the TIOBE index, a measure of the popularity of programming languages, moving up from the no. 2 spot the previous year.
In the C programming language any .h file is a file that contains constants and/or function declarations ( but no implementations, besides inline functions ). That means that when I write #include <foo.h> at the start of my .c file, I'll have to implement all those function declarations (...
I'm a physics major (Junior) who would like to learn a programming language. Many suggest Python as a good starting language, so let's suppose that is the language I want to first learn. This isn't for employability or general usefulness; rather, I'm just curious.
How exactly does one go about...
My dad gave me his old copy of "the c programming language" by Kernighan and Ritchie, but I was flicking through it and it comes across as quite old-fashioned and has a lot of random sh*t like pointer arithmetic, memory allocation etc.
Being an idiot, and one who's pretty out of practice with...
I write a Linear Search code,then ı decided ask to user "r" and "int arr".I mean,User decide their r and arr numbers.I tried scanf("%d",r); command but doesn't work
This code my first code before the decide Ask user :
#include <stdio.h>
int search(int arr[], int n, int r)
{
int i;
for...
If you're looking to get a serious but entertaining introduction to computer programming, I wholeheartedly recommend Anne, Andrew, and Genevieve's course, "Programming Fundamentals".
https://www.coursera.org/learn/programming-fundamentals
I know one of the instructors from my days at Penn, and...
Homework Statement
Analyze the code below and figure out what it outputs if it's started with this command:
The correct solution is given so i can better understand the parts of the problem.
Homework Equations
3. The Attempt at a Solution [/B]
I had typed it out and tried to get the same...
Homework Statement
I am supposed to analyze the code and find it's output without running it. Some things were unclear so i did run it and i have some things that puzzle me.
Homework Equations
3. The Attempt at a Solution [/B]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum e...
Homework Statement
This is a question from the test i had today in which we had to look at certain C code segments and deduce which code part is missing in order for the program to do what we desire. Part b) was a short questionnaire to test our knowledge about c types and declarations.
Part a)...
Homework Statement
My task is to write a program that reads from the .txt file into a list which contains two parts, the part of the text from the file and a pointer to the next element. Here are the specifications of the problem:
When reading from the file you should separate the letters from...
I was supposed to write a program that has a while loop in which two people, person1 and person2 input a string. The program runs the loop until one of the people inputs "it's over". At that time the program should exit and print out the correspodance between these two people while they were in...
Homework Statement
I have to create a program that dynamically allocates a string and uses up no extra space (The string takes up as much space as it needs to),checks if entered string is 'please stop this', if it is then the prgogram exits and if it isn't then it continues, it makes a copy of...
https://www.amazon.com/dp/0131103628/?tag=pfamazon01-20
https://www.amazon.com/dp/0133976890/?tag=pfamazon01-20
These two books are recommended by my school's C programming course and i can't decide which to buy. I have a big test in about a month in which i will have 2 hours to write 3...
Homework Statement
I am supposed to write a program in C that does the following:
It creates a 2d array from your specifications and as inputs takes only letters 'a' to 'z', 'A' to 'Z' and '*' and nothing else. It should immediately exit if something else is inputed. This array represents a...
I want to write a program that in the twodimensional array stores only capital and noncapital letters of the alphabet and the sign #. Everything else inputted cannot be stored in the array. How am i to do this in the easiest way?
I can think of only checking for each input if it exists in some...
Homework Statement
I need to write an Erdos-Renyi random graph, by using the adjacency matrix (or alternatively list) and calculate the fitness of the graph.
Definition: G(n, p) is a random graph with n vertices where each possible edge has probability p of existing.Homework Equations
The...
Hi, i wrote a code and annotated it but i have few problems with it. First it won't run on Visual Studio but it runs fine on repl.it online site which uses a C ide. Second, it seems wrong when i input
5
45 6 -4 8 3
It should print out 8 3 but for some reason it misses out on 3. Could you see...
Homework Statement
I am fairly new to C programming. I need to write a code that creates an array of max 300 numbers, ask the user to input the numbers and then print that array.
Homework Equations
3. The Attempt at a Solution [/B]
Here is my code
#include <stdio.h>
void main() {
int...
Homework Statement
Write a program that opens a file of the users choice that contains a list of birthdays. Extract from this file two things: (1) the date with the most common birthday (all of them) and (2) the month with the most people born. We will not test for a tie in either of these...
< Mentor Note -- thread moved to HH from the technical Computer forum, so no HH Template is shown >
I have a homework problem which requires me to convert a word a user entered to Pig Latin by moving the first letter of the word to the end and adding an ay to it. For example, Tuesday becomes...
Hear me out on this. I am an absolute beginner to C, i know some Python and i just finihed a month course on Pascal (school currciulum) and we're starting C by the end of February. Even though I am a beginner I am a fast learner and i want a book that is escalating moderatly or even fast.
Also...
I am trying to use C++ (eclipse in Ubuntu OS) to read USB connection. Usually, on the terminal window, I can use command "lsusb" to see the list. Now, I want to do the same way with C++.
can anyone help?
Thank you very much.
I'd like to build my own reliable alarm clock, but I don't have any knowledge in electronics and no fancy equipment, only some humble C programming experience. What do I need and what do I need to know to build one myself.
Thanks very much.
For a program to use I have to compile some .c files which include #include''header.h'' statements and I have tried different commands to compile but it gives me errors like 'No such file or directory'.
Here is start of my file named
#include "einterp.h"
while start of
file looks like this...
Hello everyone, i hate that i can't figure this out and I'm just looking for good direction on how to figure out the last bit of my code. I'm first time user of C programming and haven't fully grasp the concepts and tools available to me so be patient if you offer any help. My task is to write a...
Edited by mentor to include image inline
Hello
Please I am practicing my simple basic C Programming using Notepad++ and Cygwin64
I have written tried running the codes in the picture below, it doesn't detect any error when I run it but when I try to 'withdraw some money less Tha the fBalance...
Homework Statement
Given connected, directed and weighted (positive weights) graph. Find the shortest cyclic path for each vertex. Cycles have back edges and can also be self loops.
2. The attempt at a solution
I need some clarifications for this problem related to implementation in C.
After...
Homework Statement
Given the representation of directed unweighted graph:
typedef struct
{
int n;//num. of vertices
void *info[MAX];//information of vertices
int am[MAX][MAX];//adjacency matrix
}GRAPH;
Write a function int minDegree(GRAPH*); and int maxDegree(GRAPH*); that return the...
Homework Statement
Create a linear stack with N binary search trees (data of a tree node is an integer). Read N trees, push them on the stack. Then, empty the stack and store trees in the new array and print the content of the stack.
2. The attempt at a solution
The following code gives...
Homework Statement
Given a matrix n x m with unsigned char data type entries (entries are of size 1 byte, so data type of an entry should be unsigned or signed char, not int or char *). Entries are read in hexadecimal format (0x00,0x11,0xFF,...). Matrix should be allocated dynamically.
Print...
I have learned that in c programming language at least one function is needed. And the function is given as:
int main(){
//statements;
return 0;
}
Then when I turned to the function page (in a web tutorial) I saw functions are declared by return type-function name and parameters.
The...
Hi,
am working on a vehicle tracking device, i am using LIS3Dh accelerometer to get the acceleration data.
i am using TM4c1231e6pz controller. I need to implement a harsh breaking alert, I am having difficulty in finding out which direction the vehicle is moving since the axis are not aligned...
Homework Statement
I need help with the following problem in C programming language:
Define a quiz and add two questions in it with given possible answers. Display the questions one by one and allow the user to choose between 1, 2 or 3 (numbers that represent serial numbers of possible...
Hi all, I am looking to learn C by myself since it is a programming language that is used in my micro controllers class that i am going to take during the upcoming Spring semester at my university. I was wondering how i should go about doing this? I was thinking of using book The C Programming...
I know about For loops but i don't know how to solve a problem like this:
A program in which a user wants to print a number for specific number of times but this is not initialized i mean user inputs it after the program is compiled?
Homework Statement
The following program should create singly circular linked list
which has n arbitrary stored positive integer numbers.
Then, create BST which has all primes from the list,
and store them in text file in descending order.
Homework Equations
Linked list
Binary search tree
File...
Homework Statement
So I created two arrays one called departure_time and the other arrival_time and populate each array as follows. I've tried both putting 8 and defining N as 8
int departure_times[N]={480, 538, 679, 767, 840, 945, 1140, 1305};
int arrival_times[N]={616, 712, 811, 900, 968...
Homework Statement
How to delete specific record from a text file by some field from struct?
Homework Equations
-File handling
-Searching algorithms
The Attempt at a Solution
I know that one of the searching algorithms is needed, but could someone explain how to
delete found record from file?
What books of solved problems (free in pdf) would you recommend for data structures and algorithms in C (linked lists, trees, sorting and searching algorithms, graphs, recursion, files)?
Note: I am not looking for theoretical books, but books of solved problems.
Thanks for replies.
Homework Statement
Hi, I am currently in a C programming course and i have no background knowledge of programming whatsoever. The professor in my course isn't very good at explaining so I'm a bit lost here. (Please keep in mind, I am NOT asking anyone to do this for me. I would like to know a...
Homework Statement
I need to create data structure which contains three linked lists that are connected to one root node.
Homework Equations
-Data structuresThe Attempt at a Solution
I can't find what is wrong with the following code:
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{...
Homework Statement
I have a binary tree. I need to print a path of a doubly circular linked list (0 and 1) after every user input.
I have a code in which user inputs data about one person. For example, when user inputs 2 elements, the path should be 0->1. In my code, it won't print any path...
I have previously learned C and Python. I'm just starting out with Ruby and Scala. But I need to become more proficient in these languages, so could someone suggest good sources of problems/exercises in each of these languages
sources could include websites, books, etc.
I know there are many resources online for this but I'd to learn from someone on here. Could you provide me a lesson/project to do and finish in C language for beginners. I can get the software needed to compile and such and will post an image when I am done or provide whatever proof of...
Homework Statement
Trick Or Treat
Halloween is round the corner and it's time for trick-or-treating. You reside at the top left corner of a n-by-n town map and heading to the halloween party located at the bottom right corner. While on your trip, you decide to visit a minimal number of houses...
The Question
Winning Lines
Tic-tac-toe is a game played by two players o and x. A player wins when he/she succeeds in placing three respective marks in a horizontal, vertical or diagonal row.
Given a 3-by-3 tic-tac-toe board, a winning line is a line (row, column or diagonal) that is not...
Hi everyone. This is similar to my strcpy question previously. I tried to code but when I ran the code, a segmentation fault appears. I think this has something to do with my loop for the array but I have problems resolving it. May I have some help please? Thank you. My codes and the original...
Hi everyone. I ran into a problem while trying to code the string function, strcpy, without the use of <string.h>. The function, strcpy, which I have to make myself is exactly the same as the strcpy in <string.h>.The question in my homework is:
Implement the my_strcpy(s1,s2) function that...