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

C Programming Practical 2

Uploaded by

dhanshree1278
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

C Programming Practical 2

Uploaded by

dhanshree1278
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

‭Course Code: 23ADS1102‬ ‭Course Name: C.

Programming Lab‬

‭Name of Students: Dhanshree Gaur‬ ‭Semester : 1st Semester / Section M‬

‭Roll No: M-05‬ ‭Enroll No: 24070403‬

‭Problem Definition:‬‭‬

‭Write a program to perform arithmetic operations on values entered by the user.‬

‭Source Code in C:‬

‭#include <stdio.h>‬
‭int main() {‬
‭float num1, num2, sum, diff, product, quotient;‬
‭printf("Enter the value of num1 : ");‬
‭scanf("%f", &num1);‬
‭printf("Enter the value of num2 : ");‬
‭scanf("%f", &num2);‬
‭{‬
‭sum = num1 + num2;‬
‭diff = num1 - num2;‬
‭product = num1 * num2;‬
‭quotient = num1 / num2;‬
‭}‬
‭printf("Sum of the numbers : %f\n", sum);‬
‭printf("Difference of the numbers : %f\n", diff);‬
‭printf("Product of the numbers : %f\n", product);‬
‭printf("Quotient of the numbers : %f\n", quotient);‬
‭return 0;‬
‭}‬
‭Output:‬

‭Conclusion:‬

I‭ n‬‭this‬‭practical‬‭we‬‭studied‬‭how‬‭to‬‭perform‬‭arithmetic‬‭operation‬‭on‬‭the‬‭values‬‭entered‬‭by‬‭the‬
‭user,‬‭using‬‭printf‬‭and‬‭scanf‬‭functions.‬‭Here,‬‭%f‬‭was‬‭used‬‭as‬‭the‬‭format‬‭specifier‬‭to‬‭specify‬
‭the‬ ‭float‬ ‭value‬ ‭of‬ ‭the‬ ‭variables‬ ‭involved‬ ‭because‬ ‭it‬ ‭not‬ ‭necessary‬ ‭that‬ ‭all‬ ‭the‬ ‭results‬ ‭are‬
‭always integers with no decimals.‬

You might also like