Category Archives: Basic C Programs C Source Code

C Program Swap Two Variables using Temp

C Program Swap Two Variables #include <stdio.h> int main() { int n1,n2,temp; printf(“Enter two numbers to swap values\n”); scanf(“%d%d”, &n1, &n2); printf(“Before swapping: n1=%d and n2=%d”, n1,n2); temp = n1; n1 = n2; n2 = temp; printf(“\nAfter swapping: n1=%d and n2=%d”, n1,n2); return 0; } output Enter two numbers to swap values 220 500 Before… Read More »

Loading

C Program KM to Meters Conversion

C Program KM to Meters Conversion #include <stdio.h> int main() { int meters, kilometers; printf(“Enter distance in Kilometers=”); scanf(“%d”, &kilometers); meters = kilometers * 1000; printf(“%d Kilometers are equal to %d meters”, kilometers, meters); return 0; } Output Enter distance in Kilometers=75 75 Kilometers are equal to 75000 meters Press Enter to return to Quincy…

Loading

C Program Addition of Two Numbers

C Program Addition of Two Numbers #include <stdio.h> int main() { int addition, num1, num2; printf(“Enter two numbers to add\n”); scanf(“%d%d”, &num1, &num2); addition = num1 + num2; printf(“Sum of the numbers = %d\n”, addition); return 0; } Output Enter two numbers to add 10 200 Sum of the numbers = 210 ——————————– Process exited… Read More »

Loading