Posts

Showing posts from April, 2022

Program to calculate simple interest in C

/*calculation of simple interest*/ #include<stdio.h>   /*#include is a preprocessor directive and #include<stdio.h> is a declaration for printf() function*/ int main()              /*main() is a function or a cointainer for a set of statements*/ { int p,n;       /*declaration*/ float r,si;    /*declaration*/ p=50000;        //p=principal n=10;             //n=number of years r=2500;         //r=rate    si=p*n*r/100;    //using formula for simple interest        printf("%f\n",si);  /*printf() displays output on the screen, %f is used to print real value, and \n takes cursor to next line*/    return 0;        /*as we are using int before main(), it return a value 0*/   } In the above program, Every time we run the program we would get the same output but if you want to supply the values of p, r, and n through the keyboard during the execution, you need to use a function scanf( ).   /*calculation of simple interest, taking values from user*/ #include<s

c programming for beginners tutorial

Image
  What is c? C is a programming language developed at AT & T' s Bell laboratories of USA in 1972. It was written and designed by a man named Dennis Ritchie. Why it is called C? It is called "C" because of  it came after programming language "B" Which was created by Thompson. Why C is popular? C is popular because it is simple, easy, reliable to use. In industries new programs, tools, and technologies emerge and vanish day by day, a language that has survived for more than three decades has to be really good.  Why do we need to learn C? C++, c#, java, and many other languages use the concept of (OOP) Object Oriented Programming to organize the program. OOP has lots of advantages to offer. TO use (OOP) you would still need a good hold over the language elements of C and the basic programming skills. So it makes more sense to first learn C and then migrate to other programming languages. Characters used in C In C, Characters include any Alphabet, Digits, and Sp

Program to calculate Simple interest using scanf() function.

 /*calculation of simple interest, taking values from user*/ #include<stdio.h>   /*#include is a preprocessor directive and #include<stdio.h> is a declaration for printf() function*/ int main()          /*main() is a function or a cointainer for a set of statements*/ { int p,n;       /*declaration*/ float r,si;    /*declaration*/ printf("input values of p,n,r");  scanf("%d%d%f",&p,&n,&r);    //&(ampersand) is an address of operator, when we use &p we are telling scanf()at which memory location should it store the value.    si=p*n*r/100;  //using formula for simple interest        printf("%f\n",si);  //printf() displays output on the screen, %f is used to print real value, and \n takes cursor to next line.    return 0;        //as we are using int before main(), it return a value 0   }