Posts

Write a program to print 1+1/2+1/3+1/4+... ... ...+1/N series.

_____________ PROGRAM :   -------------------------------------------------- #include<stdio.h> #include<conio.h> void main() {   int i,j,n;   float k=0;                        \\K is Taken for ADDITION   clrscr();   printf("Enter the Number of Terms : ");   scanf("%d",&n);   for(i=1;i<=n;i++)                  \\Take a loop Up to N number   {         j=1/i;         printf("1/%d+",i);             \\print the series              k=k+j;                                 \\For addition   }        printf("SUM IS = %f",k);     \\Print the Addition       getch();     ...

Write a program to display multiplication table

_____________ PROGRAM : -------------------------------------------------- #include<stdio.h> #include<conio.h> void main() {      int i,j,n;      clrscr();      printf("Enter the Number :");      scanf("%d",&n);      for(i=1;i<=10;i++)      {                j=i*n;          printf("%d * %d=*d",n,i,j);      }        getch();      return 0; } ---------------------------------------- ___________ OUTPUT : ============================== Enter the Number :5 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5= 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50 ==============================

Write a program to print "HELLO FRIENDS".

Program: #include<stdio.h> #include<conio.h> void main() {   printf("HELLO FRIENDS");      getch(); } Output: "HELLO FRIENDS"

Program to select and print the largest number of the 3 numbers using if else statement

Program: #include<stdio.h> #include<conio.h> void main() {   int a,b,c;      printf("Enter the value of a:");    scanf("%d",&a);   printf("Enter the value of b:");   scanf("%d",&b);   printf("Enter the value of c:");   scanf("%d",&c);   if(a>b )   {     if(a>c)     {       printf("\nMaximum value:%d",a);     }   else    {       printf("\nmaximum value:%d",c);    }  }  else  {   if(b>c)    {      printf("\nMaximum value:%d",b);    }   else    {              printf("\nMaximum value:%d",c);    }  } getch(); } Output: Enter the value of a:56 Enter the value of b:84 Enter the value of c:100 Maximum value:100

Program to solve Quadratic Equation.

Program: -------------------------------------------------- #include<stdio.h> #include<conio.h> #include<math.h> void main() {   int a,b,c;   float x,x1,x2,D;   printf("enter the value of a:");   scanf("%d",&a);      printf("Enter the value of b:");   scanf("%d",&b);   printf("Enter the value of c:");   scanf("%d",&c);   D=sqrt(b*b)-(4*a*c);  if(D==0)   {       printf("roots are real and equal.");              x=((-b)/(2*a));       printf("\nx=%f",x);   }  else if(D>0)   {     printf("roots are real and distinct.");          x1=((-b+D)/(2*a));     x2=((-b-D)/(2*a));          printf("\nx1=%f",x1);     printf("\nx2=%f",x2);   }  else   {     printf("roots does not exist...

Program to convert days into months and days

Program: #include<stdio.h> #include<conio.h> void main() {   int days,month;   printf("Enter value of days:");   scanf("%d",&days);   month=days/30;   days=days%30;   printf("Value of months=%d",months);   printf("\nValue of days=%d",days);   getch(); } Output: Enter value of days;45 Value of month=1 Value of days=15

Program that reads two numbers from keyboards and gives their addition, substaction, multiplication, division and modulo.

Program: #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e,f,g; clrscr(); printf("Enter value of a:"); scanf("%d",&a); printf("Enter value of b:"); scanf("%d",&b); c=a+b; printf("\nAddition=%d",c); d=a-b; printf("\nSubstraction=%d",d); e=a*b; printf("\nMultiplication=%d",e); f=a/b; printf("\nDivision=%d",f); g=a%b; printf("\nModulo=%d",g); getch(); } Output: Enter value of a:9 Enter value of b:1 Addition=10 Substraction=8 Multiplication=9 Division=9 Modulo=0