Write a program using user-defined funtion.

The program uses a user-defined function. A function defined by the user is equivalent to a subroutine in FORTRAN or subprogram in BASIC.

#include <stdio.h>
main()
{
int a,b,c;
a = 5;
b = 10;
c = mul(a,b);
printf(" Multiplication of %d and %d is %d.", a,b,c);
}
mul(x,y)
int p,x,y;
{
p = x*y;
return(p);
}

The program will print the following output:

Multiplication of 5 and 10 is 50.

Write a program to calculater Interest rate.

The program calculates the value of money at the end of each year of investment assuming an interest rate of 11 percent and prints the year and the corresponding amount, in two columns.

  1. #include"stdio.h"
  2. #define PERIOD 10
  3. #define PRINCIPAL 5000.00
  4. main()
  5. {
  6. int year;
  7. float amount, value, inrate;
  8. amount = PRINCIPAL;
  9. inrate = 0.11;
  10. year = 0;
  11. while(year <= PERIOD)
  12. {
  13. printf("%2d %8.2f\n", year, amount);
  14. value = amount + inrate * amount;
  15. year = year + 1;
  16. amount = value;
  17. }
  18. }

The output after the execution will be :

0 5000.00
1 5550.00
2 6160.50
3 68.38.15
.
.
.
.
10 14197.11

Write a program to add two numbers.

This program performs addition on two numbers and displays the result.

#include <stdio.h>
main()
{
int number;
float amount;
number = 100;
amount = 30.75 + 75.35;
printf("%d\n", number);
printf("%5.2f", amount);
}


This program when executed will produce following output:

100
106.10

Hello World.......! in C

The beginning of programming in ' C '. The #include"stdio.h"is a standard I/O header file containing standard input and output functions and it is often required.

#include<stdio.h>
void main()
{
printf("Hello, World..........!");
}

Output :-

Hello, World..........!
 

About Me

It's Me!Hi, I'm Moinuddin. I'm a Software Engineer at WIPRO working on Microsoft .NET Technology. I'm interested in a wide range of technology topics, mainly Microsoft including Windows Azure, WCF, WPF, Silverlight and any other cool technology that catches the eye.

Site Info

ProjectCSharp.com is mainly about demonstrating real time examples in different technologies like ASP.NET, WCF, WPF, Silverlight, Azure etc..,

Followers

Help Links

Project CSharp (C#) Copyright © 2011. All Rights Reserved.