How to write a C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table in C Programming Language ?
List of functions:
- checking initial values (checkVal)
- calculate x(calX)
- calculate value(s) of y(calY)
- output the table of function(output)
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- /*
- This program calculates a given function in range given by user, stores the data in arrays
- and displays the answer in a table.
- List of functions:
- checking initial values (checkVal)
- calculate x(calX)
- calculate value(s) of y(calY)
- output the table of function(output)
- */
- int checkVal(int N) //Number of steps (N) must be greater than zero
- {
- while(N<=0)
- {
- printf("N must be a positive integer!\n");
- printf("Please enter N\n");
- scanf("%i", &N);
- }
- return N;
- }
- void calcX(float A, float B, int N, float arrayX[])
- {
- int counter=0;
- float H=(B-A)/N;
- float X;
- while(counter<=N && counter<=15)
- {
- arrayX[counter]=A+(counter*H);
- counter++;
- }
- }
- void calcY(float arrayX[], float arrayY[], int N)
- {
- float euler=2.7182818;
- float X;
- int counter=0;
- while(counter<=N && counter<=15)
- {
- float X=arrayX[counter];
- float power1=X-(1/sin(X));
- if(sin(X)==0)
- {
- arrayY[counter] = -1;
- counter++;
- }
- else
- {
- float powerEuler=pow(euler, power1);
- float Y=pow(powerEuler, 0.25);
- arrayY[counter] = Y;
- counter++;
- }
- }
- }
- void output(int N, float arrayY[], float arrayX[])
- {
- int counter=0;
- printf("Step %-12s %10s\n", "VALUE OF X", "VALUE OF Y");
- while(counter<=N && counter<=15)
- {
- if(arrayY[counter]==-1)
- {
- printf("%4i %-12f %10s\n",counter, arrayX[counter], "irrational");
- counter++;
- }
- else
- {
- printf("%4i %-12f %-10f\n",counter, arrayX[counter], arrayY[counter]);
- counter++;
- }
- }
- }
- int main()
- {
- float arrayX[16];
- float arrayY[16];
- float A;
- float B;
- int N;
- int counter=0;
- printf("Please enter start point of X\n");
- scanf("%f", &A);
- printf("Please enter end point of X\n");
- scanf("%f", &B);
- printf("Please enter number of steps N\n");
- scanf("%i", &N);
- N=checkVal(N);
- calcX(A, B, N, arrayX);
- calcY(arrayX, arrayY, N);
- output(N, arrayY, arrayX);
- return 0;
- }
Learn More :
Function
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- Write overloaded function templates for finding the roots of the linear (a * x + b = 0) and square (a * x2 + b * x + c = 0) uravneniy.Zamechanie: in function to send coefficients of the equations.
- C Program Character toupper() Example
- C Program Function Example
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program To Convert Temperature In Celsius To Fahrenheit, Using Function
- C Program To Find Simple Interest
- C Function to Check Vowel
- Factorial Program In C Using Function
- C Program For Prime Number Using Function
- C Function to xorSwap and addSwap in C Programming
- C Program to concatenate two strings without using string functions
- C Function to read instructions from the file and obey them
- C Program to Implements a dictionary's functionality.
- = (int*)malloc(sizeof(int)) ??
- Design a C function that shortens a string to 8 characters
- C Program to Implements a dictionary's functionality
- C Program that prompts the user to input a string, (whitespaces allowed)
- Local sounds functions in C Program
- Function Get the resource that will be gathered from the zone name
- C Program to Find the Size of File using File Handling Function
- Average function in C
Store
- C Program To Store Students Record In A Text File
- C Program To Store Students Record Using Structure
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
- C Program to accept data from user store that data into text file
- Find the union and intersection of two sets of integer store it in two array C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- C Program - Hash Table to store information about a student
- C Program to Input Student Details into a File For Two Subjects
given
- C Program To Find Week Day Of A Given Date
- Give me an integer and I will sum it with the previous natural numbers
- C Program to Check Given String is Palindrome or Not
- C Program That in a Given Natural Number x Insert Figure c at Position p
- Return the number of tokens given a command
- C Program reads in and spews out the attributes of a given .wav file.
- C Program Recursive function that searches for a given file in a given folder
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C program to display the transpose of given 3 X 3 matrix
- C Program to convert given decimal number into binary number
Display
- DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program To Display The Number In A Specific Formats
- C Program that Display a IBM Logo
- LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor
- Pre Order, Post order, In order Implement Binary Tree using linked list
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to display the transpose of given 3 X 3 matrix
- C Program to accept a string from user, delete all vowels from that string & display the result
- C Program To Create Two Singly Linked List and Perform Following Operation
- Create Two Singly Linked List Perform Differences Display It C Program
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
- C Program to Display a real time clock (HH:MM:SS) on the LCD
- Program to Display Pie Chart Accepting User Input C Program
- Linked List For Getting Employee Details, Display and Search For Salary C Program
- Menu driven program in the creation,display,search, insertion and deletion of a node in the linked list
- Program to display the following pattern in C
- Display the Following Pattern * ** *** **** ***** C Program
Enter by User
- C Program to Enter an ODD number between 1 and 49.
- C Program to Calculation of One Number Raised to Another
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
- C Program to find result where value and power are user given
- C Program That in a Given Natural Number x Insert Figure c at Position p
- C Program To Find Prime Number And If Number Is Not Prime Then Find Factors
- C program that lets the user choose if he wants to add a item to the shopping list or print it out
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program to Input Number by the user between 1-100
- How to Gets User Input For Height in C Programming
- Loudness Program: Gets loudness level from user; chooses a response And prints it using logical and operative statements
- C Program Exchange User Entered Text Between 2 Modules
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept string from user & convert all lower case letters into upper case letters & vice versa
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept a string from user, delete all vowels from that string & display the result
- Write a c program to accept a string from user & generate following pattern (e.g, input "abcd")
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
Calculate
- C Programm zur Berechnung von Umfang und Flächeninhalt verschiedener geomatrischer Figuren
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program to Calculate GCD using recursion
- C Program To Calculate First Numbers Using Recursion
- C Program to Calculation of One Number Raised to Another
- C Program to calculate TT and Recharge Amount
- C Program to Calculate 2 numbers with 1 operation
- Un-sortiertes Array and Sortiertes Array
- C Program Calculation of Simple Interest
- C Program to Calculation of Total and Percentage
- C Program for calculation of Gross Salary
- C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
- C Program for statistically calculating pi using a specific scheduling policy.
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program Number of Judge and Score From Each Judge
- C Program to Calculate the mathematical expression for the first n numbers
- C Program to Calculate the price of movie tickets
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
Table
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Print Table Horizontally
- C Program To Generate Multiplication Table
- Printing ASCII Table with Numbers and corresponding characters
- C Program to print table vertically
- C Program contains all the functions that interact directly with the routing table, as well as the main entry method for routing
- C Program Contains all the Functions that interact directly with routing table
Array
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- C Program Array Index Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program Array Example
- C Program to Array
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Find The Maximum And Minimum Value In An Array
- C Program To Find Union & Intersection Of Two Array
- C Program To Search A Number Inside The Array
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program To Copy One Character Array Into Another
- Returns: array of decoded values. [0] - count of values
- C Program to Check if a number is in an array[1000]
- C Program to Find max and min in array using pointer concept
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to find smallest in an array using pointer
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- C Program to Array Deserialization
- Input reads in the array positions and range for random generation.