Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

Learn everything about programming

C program for plotting of two functions

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C Program for plotting of two functions (y1=exp(-ax); y2=exp(-ax2/2)) C Programming with practical program code and step-by-step full complete explanation.

C program for plotting of two functions

C program for plotting of two functions.

 
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
    int i;
    float a,x,y1,y2;
    a=0.4;
    printf("             Y------>       ");
    printf("0----------------------------");
    
    for(x=0;x<5;x=x+0.25)
    y1=(int)(50*exp(-a*x)+0.25);
    y2=(int)(50*exp(-a*x*x/2)+0.5);

    if(y1==2)
    {
        if(x==2.5)
            printf("X  |");
        else
            printf("|");
        for(i=1;i<=y1-1;++i)
            pintf("");
        printf("#");
        continue;
    }

    if(y1>y2)
    {
        if(x==2.5)
            printf("X |");
        else
            printf(" |");
        for(i=1;i<y2-1;++i)
            printf("");
        printf("*");

        for(i=1;i<=(y1-y2-1);++i)
            printf("_");
        printf("0");
        continue;
    }
    if(x==2.5)
        printf("X|");
    else
    {
        printf(" |");
    for(i=1;i<=y1-1;++i)
        printf("");
    printf("0");

    for(i=1;i<=(y2-y1-1);++i)
        printf("_");
    printf("*");
    }
}

Output

 
0--------------------------------------------------
|                                      #
|                                    0...*
|                                 0...*
|                                0...*
|                            0...*
|                           0...*
|                        0...*
|                   0...*
|                 0...*
|               0...*
|                #
|
c coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes