Breaking News

Category Archives: Uncategorized

C Program to Compute Quotient and Remainder

Program to Compute Quotient and Remainder #include <stdio.h> int main(){ int dividend, divisor, quotient, remainder; printf("Enter dividend: "); scanf("%d", &dividend); printf("Enter divisor: "); scanf("%d", &divisor); // Computes quotient quotient = dividend / divisor; // Computes remainder remainder = dividend % divisor; printf("Quotient = %d\n", quotient); printf("Remainder = %d", remainder); return 0; } Output Enter dividend: 25 Enter divisor: 4 Quotient ... Read More »

C Program to Find the Size of int, float, double and char

Example: Program to Find the Size of a variable #include <stdio.h> int main() { int integerType; float floatType; double doubleType; char charType; // Sizeof operator is used to evaluate the size of a variable printf("Size of int: %ld bytes\n",sizeof(integerType)); printf("Size of float: %ld bytes\n",sizeof(floatType)); printf("Size of double: %ld bytes\n",sizeof(doubleType)); printf("Size of char: %ld byte\n",sizeof(charType)); return 0; } Output Size of ... Read More »

C Program to Swap Two Numbers

Example 1: Program to Swap Numbers Using Temporary Variable #include <stdio.h> int main() { double firstNumber, secondNumber, temporaryVariable; printf("Enter first number: "); scanf("%lf", &firstNumber); printf("Enter second number: "); scanf("%lf",&secondNumber); // Value of firstNumber is assigned to temporaryVariable temporaryVariable = firstNumber; // Value of secondNumber is assigned to firstNumber firstNumber = secondNumber; // Value of temporaryVariable (which contains the initial value ... Read More »

C Program to Check Whether a Character is Vowel or Consonant

The five alphabets A, E, I, O and U are called vowels. All other alphabets except these 5 vowel letters are called consonants. This program assumes that the user will always enter an alphabet character. Example #1: Program to Check Vowel or consonant #include <stdio.h> int main() { char c int isLowercaseVowel, isUppercaseVowel; printf("Enter an alphabet: "); scanf("%c",&c); // evaluates ... Read More »

Add digits of a number C PROGRAM

#include <stdio.h> int main() { int n, sum = 0, remainder; printf(“Enter an integer\n”); scanf(“%d”, &n); while (n != 0) { remainder = n % 10; sum = sum + remainder; n = n / 10; } printf(“Sum of digits of entered number = %d\n”, sum); return 0; }   OUTPUT Enter an integer 1659 Sum of digits of entered ... Read More »

Add digits of a number C PROGRAM

#include <stdio.h>   int main()  {   int n, sum = 0, remainder;     printf("Enter an integer\n");   scanf("%d", &n);     while (n != 0)   {     remainder = n % 10;     sum = sum + remainder;     n = n / 10;   }     printf("Sum of digits of entered number = %d\n", sum);     return 0; } OUTPUT Enter an integer 1659 Sum ... Read More »

Add ‘n’ numbers using array C PROGRAM

#include <stdio.h>   int main() {    int n, sum = 0, c, array[100];      printf("Enter the number of integers you want to add\n");    scanf("%d", &n);      printf("Enter %d integers\n",n);      for (c = 0; c < n; c++)    {       scanf("%d", &array[c]);       sum = sum + array[c];    }      printf("Sum = %d\n",sum);      return 0; } OUTPUT Enter the number of ... Read More »

Add ‘n’ numbers C PROGRAM

#include <stdio.h>   int main() {    int n, sum = 0, c, value;      printf("Enter the number of integers you want to add\n");    scanf("%d", &n);      printf("Enter %d integers\n",n);      for (c = 1; c <= n; c++)    {       scanf("%d",&value);       sum = sum + value;    }      printf("Sum of entered integers = %d\n",sum);      return 0; } OUTPUT Enter the ... Read More »

ASCII value of character C PROGRAM

#include <stdio.h> int main() {     char c;     printf("Enter a character: ");     scanf("%c",&c);     printf("ASCII value of %c = %d",c,c);     return 0; } OUTPUT Enter a character: A ASCII value of A = 65 Read More »

Addition of 2 matrix C PROGRAM

#include <stdio.h>   int main() {    int m, n, c, d, first[10][10], second[10][10], sum[10][10];      printf("Enter the number of rows and columns of matrix\n");    scanf("%d%d", &m, &n);    printf("Enter the elements of first matrix\n");      for (c = 0; c < m; c++)    {        for (d = 0; d < n; d++)        {            scanf("%d", &first[c][d]);        }            }      printf("Enter the elements ... Read More »

Scroll To Top