Mandalika has Published 478 Answers

How to print a one-month calendar of user choice using for loop in C?

Mandalika

Mandalika

Updated on 06-Mar-2021 18:36:13

The logic to print a one-month calendar is as follows −for(i=1;i<first;i++)    printf(" "); for(i=1;i<=noofdays;i++){    printf("%3d", i);    if((first+i-1)%7==0)       printf("\n"); }Example Live DemoFollowing example accepts number of days and first day in a month from the user and prints the calendar of a month accordingly −#include<stdio.h> int ... Read More

Write a C program to maintain cricketer’s information in tabular form using structures

Mandalika

Mandalika

Updated on 05-Mar-2021 12:14:40

ProblemHow to store the cricketer’s data in tabular form in sorted order based on average runs using structures in C Programming language.SolutionLet’s try to enter the cricketer information such as name, age, no of matches and average runs he scored. It will be entered in the console at runtime using ... Read More

Write a C program to calculate the average word length of a sentence using while loop

Mandalika

Mandalika

Updated on 05-Mar-2021 12:11:51

ProblemEnter a sentence at run time and write a code for calculating the average length of words that are present in a sentenceSolutionAlgorithmSTART Step 1: declare character, int and double variables Step 2: Enter any statement Step 3: while loop        Check condition stmt[i]=getchar()) != '\n'     ... Read More

Write a C program to print numbers in words using elseif statements

Mandalika

Mandalika

Updated on 05-Mar-2021 12:08:07

ProblemWithout using a switch case, how can you print a given number in words using the C programming language?SolutionIn this program, we are checking three conditions to print a two-digit number in words −if(no<0 || no>99)entered number is not a two digitelse if(no==0)print first number as zeroelse if(no>=10 && no<=19)Print ... Read More

Write a C program to print the message in reverse order using for loop in strings

Mandalika

Mandalika

Updated on 05-Mar-2021 12:05:26

Here we write a program to reverse the sentence without predefined functions. By using for loop, we can easily print statement in reverse order.Program 1#include<stdio.h> int main(){    char stmt[100];    int i;    printf("enter the message:\n");    for(i=0;i<stmt;i++){       stmt[i]=getchar(); //reading each char from console till enter ... Read More

Generate an even squares between 1 to n using for loop in C Programming

Mandalika

Mandalika

Updated on 05-Mar-2021 11:56:52

Even square numbers are - 22, 42, 62, 82, ……… = 4, 16, 36, 64, 100, ………AlgorithmSTART Step 1: declare two variables a and n Step 2: read number n at runtime Step 3: use for loop to print square numbers         For a=2; a*a<=n;a+=2       ... Read More

Inserting elements in an array using C Language

Mandalika

Mandalika

Updated on 05-Mar-2021 11:52:55

We can insert the elements wherever we want, which means we can insert either at starting position or at the middle or at last or anywhere in the array.After inserting the element in the array, the positions or index location is increased but it does not mean the size of ... Read More

Swapping numbers using bitwise operator in C

Mandalika

Mandalika

Updated on 05-Mar-2021 11:50:12

ProblemHow to swap the numbers using the bitwise operator in the C programming language?SolutionThe compiler swap the given numbers, first, it converts the given decimal number into binary equivalent then it performs a bitwise XOR operation to exchange the numbers from one memory location to another.AlgorithmSTART Step 1: declare two ... Read More

Write a C program to reduce any fraction to least terms using while loop

Mandalika

Mandalika

Updated on 05-Mar-2021 11:47:58

Reducing the fraction to the lowest terms means that there is no number, except 1, that can be divided evenly into both the numerator and the denominator.For example, 24/4 is a fraction, the lowest term for this fraction is 6, or 12/16 is a fraction the lowest term is 3/4.Now ... Read More

What are different types of constants in C language?

Mandalika

Mandalika

Updated on 05-Mar-2021 11:20:17

Constant is a value that cannot be changed during program execution; it is fixed.In C language, a number or character or string of characters is called a constant. And it can be any data type. Constants are also called as literals.There are two types of constants −Primary constants − Integer, ... Read More

1 2 3 4 5 6 7 ... 48 Next
Advertisements