Found 26504 Articles for Server Side Programming

Write C program to calculate balance instalment

Mandalika
Updated on 05-Mar-2021 08:40:51

796 Views

ProblemWrite a C program to calculate a balance installment that is to be paid after every month for a particular loan amount (with interest).SolutionFollowing is the formula to calculate interest when the loan amount is given −i=loanamt * ((interest/100)/12);Following calculation gives amount with interest −i=i+loanamt; firstmon=i-monthlypayment; //first month payment with interest i=firstmon * ((interest/100)/12);Program Live Demo#include int main(){    float loanamt, interest, monthlypayment;    float i, firstmon, secondmon;    printf("enter the loan amount:");    scanf("%f", &loanamt);    printf("interest rate:");    scanf("%f", &interest);    printf("monthly payment:");    scanf("%f", &monthlypayment);    //interest calculation//    i=loanamt * ((interest/100)/12);    //amount with interest    i=i+loanamt; ... Read More

C program on calculating the amount with tax using assignment operator

Mandalika
Updated on 05-Mar-2021 08:38:24

3K+ Views

ProblemWrite a C Program to enter the amount in dollars and then display the amount by adding 18% as tax.SolutionLet’s consider the restaurant person adding 18% tax to every bill of the customer.The logic applied to calculate tax is −value=(money + (money * 0.18));The money should be multiplied by 18% and add to the money, then the restaurant person can receive the amount from a customer with tax.Example Live Demo#include int main(){    float money, value;    printf("enter the money with dollar symbol:");    scanf("%f", &money);    value=(money + (money * 0.18));    printf("amount after adding tax= %f", value);    return ... Read More

How to calculate the volume of a sphere using C programming language?

Mandalika
Updated on 05-Mar-2021 08:35:37

7K+ Views

The volume of sphere is nothing but the capacity of the shape.Volume of a sphere formula is −$$V\:=\:\frac{4}{3}\Pi\:r^{3}$$AlgorithmStep 1: Enter radius of sphere at runtime Step 2: Apply the formula to variable         Volume=(4/3)*3.14*rad*rad*rad Step 3: print the volume Step 4: stopProgram 1 Live Demo#include int main(){    float vol;    int rad;    rad=20;    vol=((4.0f/3.0f) * (3.1415) * rad * rad * rad);    printf("the volume of a sphere is %f", vol);    return 0; }Outputthe volume of a sphere is 33509.335938Program 2Following is an example to find Volume and Surface Area of Sphere − Live Demo#include ... Read More

What is the use of sprintf() and sscanf() functions in C language?

Sindhura Repala
Updated on 17-Dec-2024 14:20:58

6K+ Views

The sscanf() Function The sscanf() function from the C library reads input from a string and stores the results in specified variables. Each argument must be a pointer to a variable that matches the specified type in the format string. Syntax sscanf(string, formatspecifier, &var1, &var2, ……..) Parameters The following are the parameters for the sscanf() function − The String refers to the character string to read from. The Format string refers to a character string containing the required formatting information. Var1, var2, etc., represent the individual input data items. For example, this code extracts two integers from the ... Read More

Explain reference and pointer in C programming?

Bhanu Priya
Updated on 09-Mar-2021 06:31:53

942 Views

ProblemExplain the concept of reference and pointer in a c programming language using examples.ReferenceIt is the alternate name for the variable that we declared.It can be accessed by using pass by value.It cannot hold the null values.Syntaxdatatype *variablenameFor example, int *a; //a contains the address of int type variable.PointerIt stores the address of variable.We can hold the null values using pointer.It can be access by using pass by reference.No need of initialization while declaring the variable.Syntaxpointer variable= & another variable;Example Live Demo#include int main(){    int a=2, b=4;    int *p;    printf("add of a=%d", &a);    printf("add of b=%d", &b); ... Read More

Limitations of C programming language

Bhanu Priya
Updated on 09-Mar-2021 06:30:36

4K+ Views

ProblemWhat are the limitations of C Programming when compared to other programming languages?SolutionC Language prevents or prohibits the concepts of object-oriented programming language like inheritance, polymorphism, encapsulation, and data abstraction.C programming language does not detect errors for every line of coding, it will check the bugs after the complete coding is done.It does not exhibit namespace property.C programming has an insufficient level for data abstraction, i.e., does not have very large data handling capacity.C Language does not allow the user to detect the errors with the help of exception handling features.The constructor and destructors concept is not supported by the ... Read More

How to delete the vowels from a given string using C language?

Bhanu Priya
Updated on 08-Mar-2021 10:31:28

5K+ Views

The logic we use to implement to delete the vowels from the given string is as follows −for(i=0; i

How to use Pre-defined mathematical function in C language?

Bhanu Priya
Updated on 08-Mar-2021 10:29:13

298 Views

ProblemHow to find the cube root of any given number by using the C programming language?SolutionAlgorithmStep 1: Enter any number at run time Step 2: Read from console Step 3: Compute result         Result:pow(number, 1.0/3.0) Step 4: Increment result Step 5: Print resultExampleFollowing is the C program to find the cube root of any given number −//finding cube root of given number// #include #include #include void main(){    int number, result;    printf("Enter any number: ");    scanf("%d", &number);    result=pow(number, 1.0/3.0);    result++;    printf("\Cube of %d is: %d", number, result);    getch(); }OutputWhen the above ... Read More

What are the input and output for strings in C language?

Bhanu Priya
Updated on 08-Mar-2021 10:27:24

5K+ Views

An array of characters (or) collection of characters is called a string.Input and output for stringsExampleFollowing is the C program for input and output for strings −#include main ( ){    char a[30];    printf("enter your name");    scanf ( "%s", a);    printf ("your name is %s", a);    getch ( ); }OutputWhen the above program is executed, it produces the following result −1. Enter your name : Lucky 2. Enter your name : Lucky Lol Your name is Lucky Your name is LuckyNote −‘&’ is not used for accepting strings because name of the string itself specifies the ... Read More

What is a string? Declare and initialize the strings in C language

Bhanu Priya
Updated on 08-Mar-2021 10:26:10

7K+ Views

An array of characters (or) collection of characters is called a string.DeclarationRefer to the declaration given below −char stringname [size];For example - char a[50]; a string of length 50 characters.InitializationThe initialization is as follows −Using single character constant −char string[20] = { ‘H’, ‘i’, ‘l’, ‘l’, ‘s’ ,‘\0’}Using string constants −char string[20] = "Hello":;‘\0’ is called a null character. It marks the end of the string.‘\0’ is automatically placed by the compiler, if a string is given as input. The user has to take care of placing ‘\0’ at the end if a single character is given.Accessing − There is ... Read More

Advertisements