Posts

C Program to Swap two no’s without using third variable

C Program to Swap two no’s without using third variable  #include<stdio.h> int main() {    int a, b;    printf("\nEnter value for num1 & num2 : ");    scanf("%d %d", &a, &b);    a = a + b;    b = a - b;    a = a - b;    printf("\nAfter swapping value of a : %d", a);    printf("\nAfter swapping value of b : %d", b);    return (0); }

C Program to Implement Calender Program to display Day of the month

C Program to Implement Calender Program to display Day of the month  #include<stdio.h> #include<conio.h> #include<math.h> int fm(int date, int month, int year)  {    int fmonth, leap;    //leap function 1 for leap & 0 for non-leap    if ((year % 100 == 0) && (year % 400 != 0))       leap = 0;    else if (year % 4 == 0)       leap = 1;    else       leap = 0;    fmonth = 3 + (2 - leap) * ((month + 2) / (2 * month))          + (5 * month + month / 9) / 2;    //bring it in range of 0 to 6    fmonth = fmonth % 7;    return fmonth; } int day_of_week(int date, int month, int year) {    int dayOfWeek;    int YY = year % 100;    int century = year / 100;    printf("\nDate: %d/%d/%d \n", date, month, year); ...

C Program to Convert temperature from degree centigrade to Fahrenheit

C Program to Convert temperature from degree centigrade to Fahrenheit  #include<stdio.h> int main() {     float celsius, fahrenheit;     printf("\nEnter temp in Celsius : ");     scanf("%f", &celsius);     fahrenheit = (1.8 * celsius) + 32;     printf("\nTemperature in Fahrenheit : %f ", fahrenheit);     return (0); }

C program to read the values of x, y and z and print the results expressions in one line

C program to read the values of x, y and z and print the results expressions in one line (x+y+z) / (x-y-z) (x+y+z) / 3 (x+y) * (x-y) * (y-z)  #include<stdio.h> #include<conio.h> void main() {     int x, y, z;     float a, b, c;     clrscr();     printf("\nEnter the values of x,y and z : ");     scanf("%d %d %d", &x, &y, &z);     a = (x + y + z) / (x - y - z);     b = (x + y + z) / 3;     c = (x + y) * (x - y) * (y - z);     printf("\nValue of a = %f",a);     printf("\nValue of b = %f",b);     printf("\nValue of c = %f",c);     getch(); }

C Program to find greatest in 3 numbers

C Program to find greatest in 3 numbers:  #include<stdio.h> int main()  {    int a, b, c;    printf("\nEnter value of a, b & c : ");    scanf("%d %d %d", &a, &b, &c);    if ((a > b) && (a > c))       printf("\na is greatest");    if ((b > c) && (b > a))       printf("\nb is greatest");    if ((c > a) && (c > b))       printf("\nc is greatest");    return(0); }  output Enter value for a , b & c : 10 120 21 b is greatest

C Program to find exponent Power Series !!

 C Program to find exponent Power Series !!   #include<stdio.h> #define ACCURACY 0.0001 int main() {    int n, count;    float x, term, sum;    printf("\nEnter value of x :");    scanf("%f", &x);    n = term = sum = count = 1;    while (n <= 100) {       term = term * x / n;       sum = sum + term;       count = count + 1;       if (term < ACCURACY)          n = 999;       else          n = n + 1;    }    printf("\nTerms = %d Sum = %f", count, sum);    return 0; }

C Program to Check Armstrong Number

C Program to Check Armstrong Number: A positive integer is called an Armstrong number if the sum of cubes of individual digit is equal to that number itself . example: 7 = 7^1 371 = 3^3 + 7^3 + 1^3 (27 + 343 +1) 8208 = 8^4 + 2^4 +0^4 + 8^4 (4096 + 16 + 0 + 4096). 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 +5^7 (1 + 823543 + 16384 + 1 + 823543 +128 + 78125) /* C program to check whether a number entered by user is Armstrong or not. */ #include <stdio.h> int main() {   int n, n1, rem, num=0;   printf("Enter a positive  integer: ");   scanf("%d", &n);   n1=n;   while(n1!=0)   {       rem=n1%10;       num+=rem*rem*rem;       n1/=10;   }   if(num==n)     printf("%d is an Armstrong number.",n);   else     printf("%d is not an Armstrong number.",n); }