Posts

Showing posts from March, 2016

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; }