
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1339 Articles for C

3K+ Views
To begin with, let us understand what are trailing zeros in a binary number.Trailing zerosThe position of zeros after first one from the least significant bit (LSB) is called as trailing zeros in binary number.Example104 is decimal numberBinary number of 104 is: (MSB) 1101000(LSB)Here, MSB refers to Most Significant Bit.LSB refers to Least Significant Bit.From LSB after the first bit set, there are three zero.The number of trailing zeros is three.ExampleFollowing is the program to count number of trailing zeros for a given number − Live Demo#include #include int main(){ int number, i, trail = 0, size; printf("Enter a ... Read More

3K+ Views
Consider the factors given below to write a C program to rotate the bits for a given number.Rotating the bit from left to right or right to left.In left rotation, the bits are shifted from left to right.In right rotation, the bits are shifted from right to left.Take a number and try to rotate either left or right based on user program.User has to enter the number rotation at run time along with a number.Program 1Following is the C program to apply left rotation for a given number. Live Demo#include #include int main(){ int number, rotate, Msb, size; printf("Enter ... Read More

63K+ Views
Triangle consists of three sides and three angles. Based on the three sides, there are three types of triangle −Equilateral triangle: All three sides are equal.Isosceles triangle: All two sides are equal.Scalene triangle: No sides are equal.Follow the algorithm given below for writing the respective program.AlgorithmStep 1: Declare three sides of triangle. Step 2: Enter three sides at run time. Step 3: If side1 == side2 && side2 == side3 Go to step 6 Step 4: If side1 == side2 || side2 == side3 || side3 == side1 Go to Step 7 Step 5: Else Go to step 8 Step ... Read More

4K+ Views
Enter the start and stop time with hours, minutes and seconds. Finally, we need to find the difference between start and stop time.The logic to find the difference between start and stop time is given below −while (stop.sec > start.sec){ --start.min; start.sec += 60; } diff->sec = start.sec - stop.sec; while (stop.min > start.min) { --start.hrs; start.min += 60; } diff->min = start.min - stop.min; diff->hrs = start.hrs - stop.hrs;ExampleFollowing is the program to find difference between start and stop time − Live Demo#include struct time { int sec; int min; int hrs; ... Read More

4K+ Views
An array of characters is called a string. Declaration Following is the declaration declaring an array is as follows − char stringname [size]; For example: char string[50]; string of length 50 characters Initialization Using single character constant − char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’} Using string constants − char string[10] = "Hello":; Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’. Finding maximum occurrence The logic to find the maximum occurrence of character is − ... Read More

794 Views
Follow the algorithm to write a C program which enables to count the frequency of each character.AlgorithmStep 1: Define MAX size. Step 2: Declare char and integer variables. Step 3: Read the string from console. Step 4: Find length of the string. Step 5: Initialize frequency of each character to 0. Step 6: Find total number of occurrences of each character. for(i=0; i='a' && string[i]='A' && string[i]

614 Views
Character can be (A-Z(or) a- z), digit (0-9), a white space, or a special symbol in C programming language.DeclarationFollowing is the declaration for character operations in C programming −char a= ‘A’; using a character constant.Character input / output functionsThe character input/output functions are explained below −Example − char a;scanf("%c", &a); printf ("%c", &a); a = getchar ( ); putchar (a); a = getch ( ); putch (a);ExampleFollowing is the C program for line counting using getchar() − Live Demo#include /* count lines in input */ main(){ int count, num; printf("enter multiple statements and Press cntrl+z:"); num = ... Read More

4K+ Views
A union is a memory location that is shared by several variables of different data types.SyntaxThe syntax for the pointers to unions in C programming is as follows −union uniontag{ datatype member 1; datatype member 2; ---- ---- datatype member n; };ExampleThe following example shows the usage of union of structure.union sample{ int a; float b; char c; };Declaration of union variableFollowing is the declaration for union variable. It is of three types as follows −Type 1union sample{ int a; float b; char c; }s;Type 2union{ int a; ... Read More

11K+ Views
In C programming, a union is a memory location shared by multiple variables of different data types. While we can define multiple members in a union, only one member can hold a value at any given time. This makes unions an efficient way to use the same memory space for different purposes. Declaration of Union Variable A union is a user-defined datatype in the C programming language. This allows the storage of different types of variables in the same location. A union can have multiple members, and only a single member can hold a value at any given time. Declaring ... Read More

935 Views
Structure is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structure declaration is as follows −struct tagname{ datatype member1; datatype member2; datatype member n; };Here, struct is the keyword.tagname specifies name of structure.member1, member2 specifies the data items that make up structure.ExampleThe following example shows the usage of the structure at a local scope.struct book{ int pages; char author [30]; float price; };ExampleThe following program shows the usage the structure at a local scope. Live Demo#include struct{ char name[20]; int age; int salary; ... Read More