Saturday, October 31, 2020

C program to find the smallest, middle and greatest number amongst the three given number

 #include <stdio.h>

int main()

{

    int a,b,c;

    printf("Enter a,b,c:");

    scanf("%d %d %d",&a,&b,&c);

    if(a>b)

    {

        if(a<c)

        {

            printf("%d is greatest\n",c);

            printf("%d is middle\n",a);

            printf("%d is smallest\n",b);

        }

        else if(b>c)

        {

            printf("%d is greatest\n",a);

            printf("%d is middle\n",b);

            printf("%d is smallest\n",c);

        }

        else

        {

            printf("%d is greatest\n",b);

            printf("%d is middle\n",c);

            printf("%d is smallest\n",a);

        }

    }

    else if(b<c)

    {

        printf("%d is greatest\n",c);

        printf("%d is middle\n",b);

        printf("%d is smallest\n",a);

    }

    else if(a>c)

    {

        printf("%d is greatest\n",b);

        printf("%d is middle\n",a);

        printf("%d is smallest\n",c);

    }

    else

    {

        printf("%d is greatest\n",c);

        printf("%d is middle\n",b);

        printf("%d is smallest\n",a);

    }

    return 0;

}


Shortcuts for Turbo C on keyboard

Activating menu bar: f10

Quitting a C program: Alt + X

Opening a new file: Alt + F - New

Closing a file: Alt + f3

Opening a file: f3

Saving a file: f2

Switching from one window to another: f6

Maximizing & restore: f5

Selecting text from the keyboard: Shift + arrow key

Deleting selected data: ctrl + delete

Undo: alt + backspace

Redo: Shift + alt + backspace

Copy: Ctrl + Insert

Paste: Shift + Insert

Cut (Move): shift + delete

Deleting a line: ctrl + Y

Compiling a program: alt + f9

Executing (Running) a program: ctrl + f9

Output window: alt + f5

Commenting a line (non-executable line): //


Syntax of a C program:

#include<stdio.h>                        (standard input output header file) 

#include<conio.h>                       (console input output header file)

void main()

{

    clrscr();

    getch();

}


C program to find the greatest number amongst the four given number

#include <stdio.h>

int main()

{

    int a,b,c,d;

    printf("Enter a,b,c,d:");

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a>b)

    {

        if(a>c)

        {

            if(a>d)

            {

                printf("a");

            }

            else

            {

                printf("d");

            }

        }

        else if(c>d)

        {

            printf("c");

        }

        else

        {

            printf("d");

        }

    }

    else if(b>c)

    {

        if(b>d)

        {

            printf("b");

        }

        else

        {

            printf("d");

        }

    }

    else if(d>c)

    {

        printf("d");

    }

    else

    {

        printf("c");

    }

}

C program for the pyramid combination

    *
   * *
  * * *
 * * * *
* * * * *
 * * * *
  * * *
   * *
    *

#include <stdio.h>
int main()
{
    int i,j;
    for(i=1;i<=5;i++)
    {
        for(j=4;j>=i;j--)
        {
            printf(" ");
        }
        for(j=1;j<=i;j++)
        {
            printf("* ");
        }
        printf("\n");
    }
    for(i=1;i<=5;i++)
    {
        for(j=2;j<=i;j++)
        {
            printf(" ");
        }
        for(j=4;j>=i;j--)
        {
            printf(" *");
        }
        printf("\n");
    }
}

C program for the inverse pyramid

* * * * *

 * * * *

  * * *

   * *

    * 


#include <stdio.h>

int main()

{

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=2;j<=i;j++)

        {

            printf(" ");

        }

        for(j=5;j>=i;j--)

        {

            printf("* ");

        }

        printf("\n");

    }

}

Friday, October 30, 2020

C program for the following pattern: 11111 2222 333 44 5

 11111

2222

333

44

5


#include <stdio.h>

int main() {

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=5;j>=i;j--)

        {

            printf("%d",i);

        }

        printf("\n");

    }

}

C program for the following pattern: 5 44 333 2222 11111

5

44

333

2222

11111


#include <stdio.h>

int main() {

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=1;j<=i;j++)

        {

            printf("%d",6-i);

        }

        printf("\n");

    }

}

C program of exam results

 #include <stdio.h>

int main() {

    float e,m,s,t,a;

    printf("Enter English,Maths,Science marks:");

    scanf("%f %f %f",&e,&m,&s);

    t=e+m+s;

    a=t/3;

    if(e>=35 && m>=35 && s>=35)

    {

        if(a>=70)

            printf("Distinction");

        else if(a>=60)

            printf("First Class");

        else if(a>=50)

            printf("Second Class");

        else

            printf("Pass Class");

    }

    else

        printf("Fail");

}

C program to calculate bonus

 #include <stdio.h>

int main() {

    float s,b;

    printf("Enter salary:");

    scanf("%f",&s);

    b=s*0.50;

    if(b<10000)

    {

        b=10000;

    }

    else if(b>25000)

    {

        b=25000;

    }

    printf("Bonus=%.2f",b);

}

C program for the following pattern: 1514131211 10987 654 32 1

 1514131211

10987

654

32

1


#include <stdio.h>

int main()

{

    int i,j,k=15;

    for(i=1;i<=5;i++)

    {

        for(j=5;j>=i;j--)

        {

            printf("%d",k);

            k--;

        }

        printf("\n");

    }

    return 0;

}

C program for the following pattern: 1 23 456 78910 1112131415

 1

23

456

78910

1112131415


#include <stdio.h>

int main()

{

    int i,j,k=1;

    for(i=1;i<=5;i++)

    {

        for(j=1;j<=i;j++)

        {

            printf("%d",k);

            k++;

        }

        printf("\n");

    }

    return 0;

}

C program for following pattern: 1 22 333 4444 55555

 1

22

333

4444

55555


#include <stdio.h>

int main()

{

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=1;j<=i;j++)

        {

            printf("%d",i);    

        }

    printf("\n");

    }

    return 0;

}

C program for following pattern: 54321 4321 321 21 1

 54321

4321

321

21

1


#include <stdio.h>

int main()

{

    int i,j;

    for(i=5;i>=1;i--)

    {

        for(j=i;j>=1;j--)

        {

            printf("%d",j);    

        }

    printf("\n");

    }

    return 0;

}

C program for following pattern: 55555 44444 33333 22222 11111

55555

44444

33333

22222

11111


#include <stdio.h>

int main()

{

    int i,j;

    for(i=5;i>=1;i--)

    {

        for(j=1;j<=5;j++)

        {

            printf("%d",i);    

        }

    printf("\n");

    }

    return 0;

}

C program for following method: 54321 (5 times, 4 distinct methods)

54321

54321

54321

54321

54321


First Method:

#include <stdio.h>

int main()

{

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=5;j>=1;j--)

        {

            printf("%d",j);    

        }

    printf("\n");

    }

    return 0;

}


Second Method:

#include <stdio.h>

int main() {

    int i,j;

    for(i=1;i<=5;i++)

    {

        for(j=1;j<=5;j++)

        {

            printf("%d",6-j);

        }

        printf("\n");

    }

}


Third Method:

#include <stdio.h>

int main() {

    int i,j;

    for(i=5;i>=1;i--)

    {

        for(j=1;j<=5;j++)

        {

            printf("%d",6-j);

        }

        printf("\n");

    }

}


Fourth Method:

#include <stdio.h>

int main() {

    int i,j;

    for(i=5;i>=1;i--)

    {

        for(j=5;j>=1;j--)

        {

            printf("%d",j);

        }

        printf("\n");

    }

}

Thursday, October 29, 2020

C program of salary system

First Method:

#include <stdio.h>

int main() {

    float s,e;

    char g;

    printf("Enter salary, work experience & grade:");

    scanf("%f %f %c",&s,&e,&g);

    if(e>=5)

    {

        if(g=='A'||g=='a')

        {

            s=s*2;

        }

        else if(g=='B'||g=='b')

        {

            s=s*1.75;

        }

        else if(g=='C'||g=='c')

        {

            s=s*1.60;

        }

        else if(g=='D'||g=='d')

        {

            s=s*1.50;

        }

        else

        {

            s=s*1.25;

        }

    }

    else

    {

        s=s*1.15;

    }

    printf("Net Salary=%.2f",s);

}


Second Method:

#include <stdio.h>

int main() {

    float e,s;

    char g;

    printf("Enter experience,salary and grade:");

    scanf("%f %f %c",&e,&s,&g);

    if(e>=15)

    {

        if(g=='A'||g=='a')

        {

            s=s*2;

        }

        else if(g=='B'||g=='b')

        {

            s=s*1.75;

        }

        else if(g=='C'||g=='c')

        {

            s=s*1.60;

        }

    }

    else if(e>=10)

    {

        s=s*1.5;

    }

    else if(e>=5)

    {

        s=s*1.4;

    }

    else

    {

        s=s*1.25;

    }

    printf("Net Salary=%.2f",s);

}


C program of electricity bill

 #include <stdio.h>

int main() {

    int u;

    printf("Enter units consumed:");

    scanf("%d",&u);

    if(u<=100)

        printf("Net Bill=%d",u);

    else if(u<=200)

        printf("Net Bill=%d",100+(u-100)*1);

    else if(u<=300)

        printf("Net Bill=%d",250+(u-200)*2);

    else if(u<=400)

        printf("Net Bill=%d",500+(u-300)*3);

    else

        printf("Net Bill=%d",750+(u-400)*5);

}

C program of grading system

First Method:

#include <stdio.h>

int main() {

    float e,m,s,t,a;

    printf("Enter English,Maths,Science marks:");

    scanf("%f %f %f",&e,&m,&s);

    t=e+m+s;

    a=t/3;

    printf("Total=%.2f,Average=%.2f\n",t,a);

    if(a>=70)

        printf("Distinction");

    else if(a>=60)

        printf("First Class");

    else if(a>=50)

        printf("Second Class");

    else if(a>=35)

        printf("Pass Class");

    else

        printf("Fail");

}


Second Method:

#include <stdio.h>

int main() {

    float e,m,s,t,a;

    printf("Enter English,Maths,Science marks:");

    scanf("%f %f %f",&e,&m,&s);

    t=e+m+s;

    a=t/3;

    printf("Total=%.2f,Average=%.2f\n",t,a);

    if(a<35)

        printf("Fail");

    else if(a<50)

        printf("Pass Class");

    else if(a<60)

        printf("Second Class");

    else if(a<70)

        printf("First Class");

    else

        printf("Distinction");

}

C program of admission

 #include <stdio.h>

int main() {

    float m,s,e;

    printf("Enter Maths, Science & English:");

    scanf("%f %f %f",&m,&s,&e);

    printf("Total = %.2f, Average = %.2f\n", m+s+e, (m+s+e)/3);

    if(m+s+e>=200)

    {

        printf("Admission Confirmed");

    }

    else if(m+s>=150)

    {

        printf("Admission Confirmed");

    }

    else

    {

        printf("Admission unconfirmed");

    }

}

C program to find profit or loss or nothing

#include <stdio.h>

int main() {

    float p,s;

    printf("Enter purchase & selling amount:");

    scanf("%f %f",&p,&s);

    if(p<s)

    {

        printf("Profit=%.2f",s-p);

    }

    else if(p>s)

    {

        printf("Loss=%.2f",p-s);

    }

    else

    {

        printf("No profit or loss");

    }

}

C program of the greatest or the equal number amongst two given numbers

#include <stdio.h>

int main() {

    int x,y;

    printf("Enter x & y:");

    scanf("%d %d",&x,&y);

    if(x>y)

    {

        printf("x=%d is greatest",x);

    }

    else if(y>x)

    {

        printf("y=%d is greatest",y);

    }

    else

    {

        printf("x=y=%d",x);

    }

}

Purchasing & Selling Amount (C Program)

 #include <stdio.h>

int main() {

    float p,s;

    printf("Enter purchase & selling amount:");

    scanf("%f %f",&p,&s);

    if(p<s)

    {

        printf("Profit of %.2f Rs",s-p);

    }

    else

    {

        printf("Loss of %.2f Rs",p-s);

    }

}

Wednesday, October 28, 2020

C program to find the greatest of two numbers

#include <stdio.h>

int main() 

{

    int a,b;

    printf("Enter a & b:");

    scanf("%d%d",&a,&b);

    if(a>b)

    {

        printf("a=%d is greatest",a);

    }

    else

    {

        printf("b=%d is greatest",b);

    }

    return 0;

}

Tuesday, October 27, 2020

The bar graphs and line graphs depicts about the water taken from the water resources and making use of it for different purposes in different continents. (Ielts Writing Task)

 It can be seen from the graphs that Asia has been the most withdrawing as well as most consuming water continent. In it only it is seen that the gap between withdrawal and consumption is around 1000 km cube per year which is a huge amount of water wasted.

Australia and Oceania are the least in both withdrawal and consumption. North America, South America, Europe, and Africa amount is in between Asia, Australia and Oceania.

From line graphs, it can be said that the withdrawal of water has been increasing throughout the years which will be increasing only in the near future. The consumption of water is slightly slowly increasing throughout the years which also be increasing in near future.

It can be said that the wastage has remained in huge amount throughout which also be the same in near future.

Do you feel it is better for young people learning school to study further at university or go straight into the workplace? Give reasons for your answer and include any relevant examples from your knowledge or experience (Ielts Writing Task)

Nowadays the main concern or tension for the parents regarding their child is what choice should be apt for them toward the better future amongst further studies or joining the job at the company.

Both choices have their own pros and cons which will be discussed in this essay. It is also a tough decision for the child whether to study more or join the company.

Talking about further studies can help the child acquiring more knowledge related to the specific field. It can grow the theoretical as well as practical knowledge. Also after acquiring a specific degree in the field, a special brand is been created. The person is treated in different ways as compared to the lower degree achiever, whereas some company requires work experience which will not be present in the resume of the student.

Joining at the workplace directly after studies are both good as well as bad. Because till now only the student had studied the concept or maybe has performed some practicals. So it must be a difficult situation for him/her to get settled in the working environment. But nowadays the companies are offering an internship where the student is given a hands-on experience which can help them in working easily there. Most companies provide the training related to their work whereas some assign tasks to the freshers through which the child has to go through.

Once the student goes for the job in future it will be very difficult to get back to studies if thinking of. Thus as described above both choices have their own advantages as well as disadvantages according to me.


Monday, October 26, 2020

if grade is A then salary is double otherwise 50% bonus

 #include <stdio.h>

int main() 

{

    float s;

    char g;

    printf("Enter salary & grade:");

    scanf("%f %c",&s,&g);

    if(g=='A')

    {

        s=s*2;

    }

    else

    {

        s=s*1.5;

    }

    printf("Net Salary=%.2f",s);

}

If work experience is greater than 5 then bonus 50% otherwise 25%

 #include <stdio.h>

int main() 

{

    float s,e;

    printf("Enter salary & work experience:");

    scanf("%f %f",&s,&e);

    if(e>=5)

    {

        printf("Net Salary=%.2f",s*1.5);

    }

    else

    {

        printf("Net Salary=%.2f",s*1.25);

    }

}

Sunday, October 25, 2020

C program: If the purchase amount is greater than 2000 20% discount otherwise 5% discount

First Method:

#include <stdio.h>

int main() {

    float n;

    printf("Enter the purchase amount:");

    scanf("%f",&n);

    if(n>=2000)

    {

        printf("Net Pay=%.2f",n-(n*0.20));

    }

    else

    {

        printf("Net Pay=%.2f",n-(n*0.05));

    }

}

Second Method:

#include <stdio.h>

int main() {

    float n;

    printf("Enter the purchase amount:");

    scanf("%f",&n);

    if(n>=2000)

    {

        printf("Net Pay=%.2f",n*0.80);

    }

    else

    {

        printf("Net Pay=%.2f",n*0.95);

    }

}

C program to check whether the given year is a leap year or not

#include <stdio.h>

int main() {

    int y;

    printf("Enter a year:");

    scanf("%d",&y);

    if(y%4==0)

    {

        printf("%d is a leap year",y);

    }

    else

    {

        printf("%d is not a leap year",y);

    }

}

C program to display the negative of the given positive number and vice-versa

 #include <stdio.h>

int main() {

    int n;

    printf("Enter a number:");

    scanf("%d",&n);

    n=-n;

    printf("Number=%d",n);

}

Saturday, October 24, 2020

c program to display whether the given number is even or odd

 #include <stdio.h>

int main() {

    int n;

    printf("Enter a number:");

    scanf("%d",&n);

    if(n%2==0)

    {

        printf("N is even", n);

    }

    else

    {

        printf("N is odd",n);

    }

}

If the given number is positive, display the square and the cube otherwise display an error (C program)

#include <stdio.h>

int main() {

    int n;

    printf("Enter a number:");

    scanf("%d",&n);

    if(n>0)

    {

        printf("Square=%d, Cube=%d",n*n,n*n*n);

    }

    else

    {

        printf("Enter a positive number");

    }

}

If the grade is A then double the salary (c program)

 #include <stdio.h>

int main() {

    float s;

    char g;

    printf("Enter salary and grade:");

    scanf("%f %c", &s, &g);

    if(g=='A')

    {

        s=s*2;

    }

    printf("Net Salary=%.2f",s);

}

If the work experience is more than 5 years then the bonus is 50%

 #include <stdio.h>

int main() {

    float we,s;

    printf("Enter Work Experience & Salary:");

    scanf("%f%f",&we,&s);

    if(we>=5)

    {

        s=s*1.5;

    }

    printf("Salary=%.2f",s);

}

If the purchase amount is more than 2000 Rs, the discount is of 20%

#include <stdio.h>

int main() {

    float pa;

    printf("Enter Purchase Amount:");

    scanf("%f",&pa);

    if(pa>=2000)

    {

        pa = pa - (pa*0.2);

    }

    printf("Net Payable=%.2f",pa);

}

c program to check whether the given year is not a leap year

 #include <stdio.h>

int main() {

    int y;

    printf("Enter year:");

    scanf("%d",&y);

    if(y%4!=0)

    {

        printf("%d is not a leap year",y);

    }

}

c program to check whether the given year is a leap year

#include <stdio.h>

int main() {

    int y;

    printf("Enter year:");

    scanf("%d",&y);

    if(y%4==0)

    {

        printf("%d is a leap year",y);

    }

}

Friday, October 23, 2020

Based on the work experience and grade, calculate the net salary in C.

#include <stdio.h>

int main() 

{

    float s,e;

    char g;

    printf("Enter s,e,g");

    scanf("%f %f %c",&s,&e,&g);

    if(e>=5)

    {

        if(g=='a'||g=='A')

        {

            s=s*2;

        }

        else if(g=='B'||g=='b')

        {

            s=s*1.75;

        }

        else if(g=='c'||g=='C')

        {

            s=s*1.60;

        }

        

        else if(g=='D'||g=='d')

        {

            s=s*1.50;

        }

        else

        {

            s=s*1.25;

        }

    }

printf("Net Salary:%.2f",s);

}

Calculate the net salary based on work experience and grade in C

 #include <stdio.h>

int main() 

{

    float e, s;

    char g;

    printf("Enter e,s,g");

    scanf("%f %f %c",&e,&s,&g);

    if(e>=15)

    {

        if(g=='A'||g=='a')

        {

            s=s*2;

        }

        else if(g=='B'||g=='b')

        {

            s=s*1.75;

        }

        else if(g=='C'||g=='c')

        {

            s=s*1.60;

        }

    }

    else if(e>=10)

    {

        s=s*1.5;

    }

    else if(e>=5)

    {

        s=s*1.4;

    }

    else

    {

        s=s*1.25;

    }

    printf("Net Salary=%.2f",s);

}

Wednesday, October 21, 2020

c program to display if the given number is odd (2 different methods)

First Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n%2!=0)

    {

        printf("Number=%d is odd",n);

    }

}


Second Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n%2==1)

    {

        printf("Number=%d is odd",n);

    }

}

if the given number is greater than 0 calculate its square and cube - c program

#include <stdio.h>

int main() 

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n>0)

    {

        printf("Number = %d, Square = %d, Cube = %d", n, n*n, n*n*n);

    }

}

Display the given number if it is equal to zero in c

 #include <stdio.h>

int main() 

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n==0)

    {

        printf("Number is zero");

    }

}

Monday, October 19, 2020

Display the given number if it is negative using if statement in c

 #include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n<0)

    {

        printf("%d is negative", n);

    }

    return 0;

}

display the double of the given number if it is less than 50 in c

 #include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n<50)

    {

        printf("Number = %d", n*2);

    }

    return 0;

}

c program to display the given number if it is less than 25

 #include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n<25)

    {

        printf("Number = %d", n);

    }

    return 0;

}

display the given number if it is greater than 100

 #include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    if(n>=100)

    {

        printf("Number = %d", n);

    }

    return 0;

}

swapping numbers in c (2 unique different methods)

First Method:

#include <stdio.h>

int main()

{

    int a, b, c;

    printf("Enter A & B:");

    scanf("%d%d", &a, &b);

    printf("Before swapping: a = %d, b = %d", a, b);

    c=a;

    a=b;

    b=c;

    printf("\nAfter swapping: a = %d, b = %d", a, b);

    return 0;

}


Second Method:

#include <stdio.h>

int main()

{

    int a, b, c;

    printf("Enter A & B:");

    scanf("%d%d", &a, &b);

    printf("Before swapping: a = %d, b = %d", a, b);

    a=a+b;

    b=a-b;

    a=a-b;

    printf("\nAfter swapping: a = %d, b = %d", a, b);

}

c program of bonus in net salary

First Method:
#include <stdio.h>
int main() {
    float s, b, ns;
    printf("Enter salary:");
    scanf("%f", &s);
    b = s * 0.50;
    ns = s + b;
    printf("Net Salary = %.2f", ns);
    return 0;
}

Second Method:
#include <stdio.h>
int main() {
    float ns;
    printf("Enter salary:");
    scanf("%f", &s);
    ns = ns + (ns * 0.50);
    printf("Net Salary = %.2f", ns);
    return 0;
}

Third Method:
#include <stdio.h>
int main() {
    float ns;
    printf("Enter salary:");
    scanf("%f", &s);
    printf("Net Salary = %.2f", ns * 0.5);
    return 0;
}

c program of salary net pay with discount

First Method:

#include <stdio.h>

int main() {

    float n, d, np;

    printf("Enter a number:");

    scanf("%f", &n);

    d = n * 0.10;

    np = n - d;

    printf("Pay Rs = %.2f", np);

    return 0;

}


Second Method:

#include <stdio.h>

int main() {

    float np;

    printf("Enter a number:");

    scanf("%f", &np);

    np = np - (np * 0.10);

    printf("Pay Rs = %.2f", np);

    return 0;

}


Third Method:

#include <stdio.h>

int main() {

    float np;

    printf("Enter a number:");

    scanf("%f", &np);

    printf("Pay Rs = %.2f, np * 0.9);

    return 0;

}

How to find given percent of the given number in c

#include <stdio.h>

int main() {

    float n, p;

    printf("Enter a number and percentage:");

    scanf("%f%f", &n, &p);

    printf("Number and percent of the number is %.2f and %.2f", n, n*(p/100));

    return 0;

}

c program to find 20% of a number

#include <stdio.h>

int main() {

    float n;

    printf("Enter a number:");

    scanf("%f", &n);

    printf("Answer is %.2f", n*0.20);

    return 0;

}

Sunday, October 18, 2020

c program to find cube and square of a number (3 distinct methods)

First Method:

#include <stdio.h>

int main() {

    int n, s, c;

    printf("Enter Number:");

    scanf("%d", &n);

    s = n * n;

    c = n * n * n;

    printf("Number = %d", n);

    printf("\nSquare = %d, Cube = %d", s, c);

    return 0;

}


Second Method:

#include <stdio.h>

int main() {

    int n;

    printf("Enter Number:");

    scanf("%d", &n);

    printf("Number = %d", n);

    printf("\nSquare = %d, Cube = %d", n*n, n*n*n);

    return 0;

}


Third Method:

#include <stdio.h>

int main() {

    int n;

    printf("Enter Number:");

    scanf("%d", &n);

    printf("Number = %d, Square = %d, Cube = %d", n, n*n, n*n*n);

    return 0;

}

Saturday, October 17, 2020

c program to find the cube of a number (3 different methods)

First Method:

#include <stdio.h>

int main()

{

    int n, c;

    printf("Enter a number:");

    scanf("%d", &n);

    c = n * n * n;

    printf("Number = %d", n);

    printf("\nCube = %d", c);

    return 0;

}


Second Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    printf("Number = %d", n);

    printf("\nCube = %d", n * n * n);

    return 0;

}


Third Method:

#include <stdio.h>

int main()

{

    int n;

    printf("Enter a number:");

    scanf("%d", &n);

    printf("Number = %d \n Cube = %d", n, n * n * n);

    return 0;

}

simple c program to half the number

 #include <stdio.h>

int main()

{

    int n;

    printf("Enter n:");

    scanf("%d", &n);

    n = n / 2;

    printf("Answer = %d", n);

    return 0;

}

c program to double the number

#include <stdio.h>


int main()

{

    int n;

    printf("Enter n:");

    scanf("%d",&n);

    n = n * 2;

    printf("Answer = %d", n);


    return 0;

}

How to Fight Overthinking or Negative Thoughts?

How to Combat Overthinking or Negative Thoughts? 1. Don’t Fight Your Thoughts Trying to suppress or control negative thoughts often backfire...