Skip to content

This is a C program to add two distances in feet and inches by using pointers

Notifications You must be signed in to change notification settings

Santhu91139/Programbypointer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

// This is a C program to add two distances in feet and inches by using pointers

#include <stdio.h> struct Distance { int feet; int inch; }; void main() { struct Distance d1,d2,result; printf("Enter 1st distance\n"); printf("Enter feet:\n"); scanf("%d", &d1.feet); printf("Enter inch:\n"); scanf("%d", &d1.inch); printf("Enter 2nd distance\n"); printf("Enter feet:\n"); scanf("%d", &d2.feet); printf("Enter inch:\n"); scanf("%d", &d2.inch); result.feet = d1.feet + d2.feet; result.inch = d1.inch + d2.inch; while (result.inch >= 12) { result.inch = result.inch - 12; ++result.feet; printf("Sum of distances = %d.%d\n", result.feet, result.inch); } }

About

This is a C program to add two distances in feet and inches by using pointers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published