Category Archives: Basic C Programs for Beginners

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