0% found this document useful (0 votes)
10 views

100_C_Programs_TurboC_Updated

This document provides a collection of 100 C programs designed for Turbo C++, covering fundamental concepts including pointers. Each program is formatted with standard Turbo C++ functions and demonstrates various programming tasks such as basic arithmetic, control structures, and pointer manipulation. Examples include programs for printing 'Hello World', checking even or odd numbers, calculating factorials, and generating Fibonacci series.

Uploaded by

anshs9333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

100_C_Programs_TurboC_Updated

This document provides a collection of 100 C programs designed for Turbo C++, covering fundamental concepts including pointers. Each program is formatted with standard Turbo C++ functions and demonstrates various programming tasks such as basic arithmetic, control structures, and pointer manipulation. Examples include programs for printing 'Hello World', checking even or odd numbers, calculating factorials, and generating Fibonacci series.

Uploaded by

anshs9333
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

100 C Programs for Turbo C++

This document contains C programs focused on basic concepts up to

pointers, formatted for Turbo C++ (void main(), clrscr(), getch()).


1. Hello World

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

void main() {
clrscr();
printf("Hello, World!");
getch();
}
2. Addition of Two Numbers

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

void main() {
int a, b, sum;
clrscr();
printf("Enter two numbers: ");
scanf("%d%d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
getch();
}
3. Check Even or Odd

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

void main() {
int num;
clrscr();
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0) {
printf("%d is Even", num);
} else {
printf("%d is Odd", num);
}
getch();
}
4. Largest of Two Numbers

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

void main() {
int a, b;
clrscr();
printf("Enter two numbers: ");
scanf("%d%d", &a, &b);
if (a > b) {
printf("%d is greater", a);
} else {
printf("%d is greater", b);
}
getch();
}
5. Sum of First N Natural Numbers

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

void main() {
int n, sum = 0, i;
clrscr();
printf("Enter the value of n: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
sum += i;
}
printf("Sum of first %d natural numbers = %d", n, sum);
getch();
}
6. Factorial of a Number

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

void main() {
int n, i, fact = 1;
clrscr();
printf("Enter a number: ");
scanf("%d", &n);
for (i = 1; i <= n; i++) {
fact *= i;
}
printf("Factorial of %d = %d", n, fact);
getch();
}
7. Prime Number Check

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

void main() {
int n, i, flag = 1;
clrscr();
printf("Enter a number: ");
scanf("%d", &n);
for (i = 2; i <= n / 2; i++) {
if (n % i == 0) {
flag = 0;
break;
}
}
if (flag == 1) {
printf("%d is a Prime Number", n);
} else {
printf("%d is not a Prime Number", n);
}
getch();
}
8. Fibonacci Series

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

void main() {
int n, a = 0, b = 1, c, i;
clrscr();
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series: %d %d", a, b);
for (i = 3; i <= n; i++) {
c = a + b;
printf(" %d", c);
a = b;
b = c;
}
getch();
}
9. Pointer Basics

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

void main() {
int a = 10, *p;
clrscr();
p = &a;
printf("Value of a = %d\n", a);
printf("Address of a = %p\n", p);
printf("Value at address p = %d", *p);
getch();
}
10. Swap Numbers Using Pointers

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

void swap(int *x, int *y) {


int temp = *x;
*x = *y;
*y = temp;
}

void main() {
int a, b;
clrscr();
printf("Enter two numbers: ");
scanf("%d%d", &a, &b);
printf("Before Swap: a = %d, b = %d\n", a, b);
swap(&a, &b);
printf("After Swap: a = %d, b = %d", a, b);
getch();
}

You might also like