Table Of Contents
- C Program to Print Hello World
- C Program to add Two numbers
- C Program to Calculate Compound Interest
- C Program to Check Odd or Even
- C Program to Print Multiplication Table using For Loop
Basic C Programs
1) C Program to Print Hello World
Code: |
---|
#include <stdio.h> int main() { printf("\n Hello World"); return 0; } |
Output: |
2) Program to add Two numbers
Code: |
---|
#include <stdio.h> int main() { int number1, number2, sum; printf(" Enter two integer values \n "); scanf("%d %d", &number1, &number2); sum = number1 + number2; printf(" Sum of the two integer values is %d", sum); return 0; } |
Output: |
3) C Program to Calculate Compound Interest
Code: |
---|
#include <stdio.h> #include <math.h> int main() { float PAmount, ROI, Time_Period, CIFuture, CI; printf("\nPlease enter the Principal Amount : \n"); scanf("%f", &PAmount); printf("Please Enter Rate Of Interest : \n"); scanf("%f", &ROI); printf("Please Enter the Time Period in Years : \n"); scanf("%f", &Time_Period); CIFuture = PAmount * (pow(( 1 + ROI/100), Time_Period)); CI = CIFuture - PAmount; printf("\nFuture Compound Interest for Principal Amount %.2f is = %.2f", PAmount, CIFuture); printf("\nCompound Interest for Principal Amount %.2f is = %.2f", PAmount, CI); return 0; } |
Output: |
4) C Program to Check Odd or Even
Code: |
---|
#include <stdio.h> int main() { int number; printf(" Enter an int value to check Even or Odd \n"); scanf("%d", &number); if ( number%2 == 0 ) //Check whether remainder is 0 or not printf("Given number %d is EVEN NUMBER \n", number); else printf("Given number %d is ODD NUMBER \n", number); return 0; } |
Output: |
5) C Program to Print Multiplication Table using For Loop
Code: |
---|
|
Output: |
More Questions Coming Soon..
Tags:
C Programs